Created
March 1, 2011 11:39
-
-
Save TowardsDeath/849013 to your computer and use it in GitHub Desktop.
Find articles with all given tags (Linq/LLBLGen)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tags = from t in data.Tag | |
where t.Title == tagTitle || t.Title == subTagTitle | |
select t.Id; | |
var list = ( from articlesWithTags in | |
( | |
from articleTag in data.ArticleTag | |
where tags.Contains( articleTag.TagId ) | |
select articleTag | |
) | |
group articlesWithTags by articlesWithTags.ArticleId into grouped | |
let count = grouped.Count() | |
where count == tags.Count() | |
join a in data.Article on grouped.Key equals a.Id | |
select a ).Distinct().WithPath( path => path.Prefetch<ProfileEntity>( a => a.User ) | |
.Prefetch<TagEntity>( a => a.TagCollectionViaArticleTag ) | |
.FilterOn( t => t.TagForRole.Where( tr => tr.TagId == t.Id ).Count() == 0 ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment