Quantcast
Viewing latest article 25
Browse Latest Browse All 45

Constraining queries based on aggregations of properties of associations

Quick question: would this trigger one query per each Tag item?

public static IQueryable<Tag> WhereTagHasLivePosts(this IQueryable<Tag> q){    return q.Where(t => t.Posts.Where(p => DateTime.Now >= p.PublishTime && p.IsPublished == true).Count() > 0);}

t.Posts.Where is actually an extension on IEnumerable, rather than IQueryable, so it seems like this might not be a good idea.

Thanks in advance,

Rei


Viewing latest article 25
Browse Latest Browse All 45

Trending Articles