Fixing tags queries

QueryOver doesn't support the Any() operator on a relationship. The current
Linq implementation supports it but is using Hql, so it can't be reused. The
QueryOver uses Criteria. The old NHibernate.Linq implementation is not
compatible with NH3. Though it was using the Criteria API.

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-08-16 15:20:00 -07:00
parent 600a8c00fe
commit 40a11218c6

View File

@@ -131,9 +131,9 @@ namespace Orchard.Tags.Services {
public IEnumerable<IContent> GetTaggedContentItems(int tagId, int skip, int take, VersionOptions options) {
return _orchardServices.ContentManager
.Query<TagsPart, TagsPartRecord>()
.Where(tpr => tpr.Tags.Any(tr => tr.TagRecord.Id == tagId))
.Join<CommonPartRecord>().OrderByDescending(x => x.CreatedUtc)
.HqlQuery<TagsPart>()
.Where(tpr => tpr.ContentPartRecord<TagsPartRecord>().Property("Tags", "tags"), x => x.Eq("TagRecord.Id", tagId))
.OrderBy(alias => alias.ContentPartRecord<CommonPartRecord>(), x => x.Desc("CreatedUtc"))
.Slice(skip, take);
}
@@ -143,8 +143,8 @@ namespace Orchard.Tags.Services {
public int GetTaggedContentItemCount(int tagId, VersionOptions options) {
return _orchardServices.ContentManager
.Query<TagsPart, TagsPartRecord>()
.Where(tpr => tpr.Tags.Any(tr => tr.TagRecord.Id == tagId))
.HqlQuery<TagsPart>()
.Where(tpr => tpr.ContentPartRecord<TagsPartRecord>().Property("Tags", "tags"), x => x.Eq("TagRecord.Id", tagId))
.Count();
}