I follow the repository pattern and the following method is in my normal repository class:
Public Virtual T (Expression & lt; Func & lt; T, bool & gt; where) {Return dbset.Where (where) FirstOrDefault & lt; T & gt; (); }
I would like to add a lambda expression with navigation properties. it's possible?
This is a method you can do
public virtual IQueryable & lt; T & gt; Include (this IQueryable & lt; T & gt; curie, parameter string []) {foreach (included in various inc) qry = qry.Include (inc); Return curie; }
Example Usage:
var list = context.Products.Where (x => x.ProductID == 1). Include ("item", "person"). Solo ();
Comments
Post a Comment