Eric Nielsen Eric Nielsen - 1 year ago 160
C# Question

fetch with Entity Framework

I just copy and post below method from here , this is the definition :

public IList<Post> PostsForCategory(string categorySlug, int pageNo, int pageSize)
var query = _session.Query<Post>()
.Where(p => p.Published && p.Category.UrlSlug.Equals(categorySlug))
.OrderByDescending(p => p.PostedOn)
.Skip(pageNo * pageSize)
.Fetch(p => p.Category);

query.FetchMany(p => p.Tags).ToFuture();

return query.ToFuture().ToList();

But, I'm using Entity framework instead of NHibernate, but EntityFramework doesn't have any definition for
! How can I do that with Entity framework?

Answer Source

You do this through the Include method:

Note, Include is an extension method, so you'll have to add System.Data.Entity to your using statements before it will compile.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download