There are a lot of posts about how cool POCO objects are and how Entity Framework 4 supports them. I decided to try it out with domain driven development oriented architecture and finished with domain entities that has dependencies from services. So far so good. Imagine my Products are POCO objects. When i query for objects like this:
NorthwindContext db = new NorthwindContext();
var products = db.Products.ToList();
EF creates instances of products for me.
Now I want to inject dependencies in my POCO objects (products) The only way I see is make some method within NorthwindContext that makes something like pseudo-code below:
public List<Product> GetProducts(){
var products = database.Products.ToList();
container.BuildUp(products); //inject dependencies
return products;
}
But what if i want to make my repository to be more flexible like this:
public ObjectSet<Product> GetProducts() { ... }
So, I really need a factory to make it more lazy and linq friendly. Please help !