I would recommend reading this.
ncqrs provides a framework to architect an application utilizing CQRS and Event Sourcing. I am sure you have read about this if you are interested in ncqrs. The thing to keep in mind is you don't save the state of your domain object, rather you save the events that have occurred on the domain object. Then you build the domain object by playing those events when you need the latest version of the domain object. This means you cannot mix and match domain objects the way you have in your model. Unless Globe is a value object (which I highly doubt) this does not belong on the server object. To me they both look like separate
On one hand you have an EF model and on the other hand you are trying to use ncqrs. I would highly recommend educating yourself about this before jumping into it with a real project.
Hope it helps.
Sent from Windows Mail
From: T.C. Boring
Sent: May 3, 2013 7:18 PM
To: abdul....@gmail.com Subject: Re: Advanced Ncqrs Examples
Sorry, I meant types in my domain that have properties that are types in the domain--not events. My bad.
Example: In my read model, I have Servers and Globes. Each server represents a web server, and has, among other things, a collection of Globes. Each globe represents a Google Earth globe, and has, among other things, a collection of servers. In EF, they look like this:
public class Server : ReadModelEntity
{
#region Constructor(s) & Destructor(s)
internal Server()
{
this.Globes = new HashSet<Globe>();
}
#endregion
#region Property(s)
public virtual ICollection<Globe> Globes { get; set; }
public string Name { get; set; }
#endregion
}
public class Globe : ReadModelEntity
{
#region Field(s)
private Uri uri;
private string uriString;
#endregion
#region Constructor(s) & Destructor(s)
internal Globe()
{
this.GlobeProperties = new HashSet<GlobeProperty>();
this.Servers = new HashSet<Server>();
}
#endregion
#region Property(s)
public virtual ICollection<GlobeProperty> GlobeProperties { get; set; }
public virtual ICollection<Server> Servers { get; set; }
public Uri Uri
{
get
{
return this.uri;
}
set
{
this.uri = value;
this.uriString = this.uri.ToString();
}
}
public string UriString
{
get
{
return this.uriString;
}
set
{
this.uriString = value;
this.uri = new Uri(this.uriString);
}
}
public string Realm { get; set; }
#endregion