Skip to content

Instantly share code, notes, and snippets.

@TowardsDeath
Created February 17, 2011 11:43
Show Gist options
  • Save TowardsDeath/831558 to your computer and use it in GitHub Desktop.
Save TowardsDeath/831558 to your computer and use it in GitHub Desktop.
Tag-and-role query with Linq / LLBLGen
var tags = from tag in data.Tag
join articleTag in data.ArticleTag on tag.Id equals articleTag.TagId
join articlesWithRole in
(
from articleTag in data.ArticleTag
join tagRole in data.TagForRole on articleTag.TagId equals tagRole.TagId
select new
{
ArticleId = articleTag.ArticleId,
Role = tagRole.Role
}
) on articleTag.ArticleId equals articlesWithRole.ArticleId
where !( from tagRole in data.TagForRole
select tagRole.TagId ).Contains( tag.Id )
&& tag.IsMainTag
select new
{
Role = articlesWithRole.Role,
Tag = new TagEntity
{
Id = tag.Id,
Title = tag.Title,
Description = tag.Description
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment