It seems to be around DDDs, repositories, data cards, etc. there is a lot of noise, and very little code for implementing the “real world” to show newcomers how I am, what is “good”, and what is “bad”.
I just finished reading the book “Enterprise Application Archiving , ” and that was a huge discovery. I am currently using the Active Record template for a project at work and am working on changing it to use the Domain Model. I used many examples of architecture in the book, and also downloaded the Northwind Starter Kit code, which is a companion for the book.
Everything went fine, but now I hit my first problem with real-world data implementation ... aka, instead of my cartographer just being responsible for accepting one Entity object and storing it in the database, now I have an Entity object, which has an IList <> collection, which should also be displayed.
The main Entity object is Expert, here is the code:
public class Expert
{
public int ID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public virtual IList<Case> Cases { get; protected set; }
}
Here is the implementation of the collection from Expert, the Case object:
public class Case
{
public int ID { get; set; }
public string Name { get; set; }
}
It could not be much easier.
Now I have a DataMapper for each Entity element, but my question is when I am going to draw a Case collection in my ExpertDataMapper code, what is considered the “right” way to do this?
SQL, ExpertDataMapper, ADO.NET, Case IList . :
public virtual void Create(Expert expert)
{
SqlHelper.ExecuteNonQuery(ProviderHelper.ConnectionString, CommandType.Text,
"SQL TO INSERT EXPERT", this.BuildParamsFromEntity(expert));
foreach (Case c in expert.Cases)
{
SqlHelper.ExecuteNonQuery(ProviderHelper.ConnectionString, CommandType.Text,
"SQL TO INSERT CASE", this.BuildParamsFromEntity(order));
}
}
, :
- ExpertDataMapper SQL ( proc), Case? ... ExpertDataMapper , Case , CaseDataMapper.
, ExpertDatMapper Case CaseDataMapper... , DataMapper . DataMappers? , , , .
- 100 , , 100 100 ? - "" . , SQL Server 2008, , , 2005 .
, DataMappers, , .. DataMaper . , , ( , ).
EAA, , , , . ORM, , DAL . EF 4.0, . ORM.
/, , , , - Entity , , DataMapper, ...
, Active Record .
, , ? , , , , , .