NHibernate Linq - Duplicate Records
Posted
by adegiamb
on Stack Overflow
See other posts from Stack Overflow
or by adegiamb
Published on 2010-03-11T21:05:02Z
Indexed on
2010/03/11
21:09 UTC
Read the original article
Hit count: 225
I am having a problem with duplicate blog post coming back when i run the linq statement below.
The issue that a blog post can have the same tag more then once and that's causing the problem. I know when you use criteria you can do the followingcriteria.SetResultTransformer(new DistinctRootEntityResultTransformer());
How can I do the same thing with linq?
List<BlogPost> result = (from blogPost in _session.Linq<BlogPost>()
from tags in blogPost.Tags
where tags.Tag == tag && blogPost.IsPublished
&& blogPost.Slug != slugToExclude
orderby blogPost.DateCreated descending
select blogPost).Distinct()
.Skip(recordsToSkip).Take(pageSize).ToList();
© Stack Overflow or respective owner