MyObjectFactory calls a EntityFramework (EF) DAL and load a Entity with several childs. The ObjectFactory maps the result to a CSLA BusinessObject.
The child entities are already loaded with a .Include(...) in the same EF query and there is no need to call the database again. How should no map the child-entites to child CSLA child business objects?
Should I define another ObjectFactory for the childs and define a GetChildList method that takes a EF Object List as a argument to avoid another call to the database?
My personal preference is to map BO and ObjectFactory 1:1.
So I would create a
Thank you for your feedback.
Does this mean u recommend this:
public class MainBOObjectFactory
public MainBO Fetch(int id)
var query = from c in ctx.Products.Include("Orders") select c;
var result = query.First();
var childs = new ChildBOObjectFactory().FetchList(result.Orders);
LoadProperty(... properties ...);
LoadProperty(... childList ...);
public class ChildBOObjectFactory
public ChildBOList FetchList(IEnumerable<Order> orders)
//for each: map an order to a childBo
Copyright (c) Marimer LLC