Fixing [Aggregate] usage

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-08-17 08:53:50 -07:00
parent 40a11218c6
commit 1ee76aa7fd
3 changed files with 13 additions and 9 deletions

View File

@@ -8,5 +8,5 @@ e57f4a5dffac99ac64e195ae6ee5f2d720876b52 src/Orchard.Web/Modules/Orchard.Rules
c85cd1e9651e3e0bb1ca97442ce390bf34cf3c76 src/Orchard.Web/Modules/Orchard.TaskLease
6ce83f60624b333aa6e23e756c07181d9df40094 src/Orchard.Web/Modules/Orchard.Tokens
1b4c795960358a84c743eeb6bd778fabbdf8455e src/orchard.web/Modules/Orchard.Alias
a5b0e6345d1a316e7184d1e77905e1300390756e src/orchard.web/Modules/Orchard.Projections
8ca57ca0486ad535c6c5d6940ad6c4ddd71130d2 src/orchard.web/Modules/Orchard.Projections
2f1aeab07e777f9ba2cf2ed6db7dcd2da831fd97 src/orchard.web/modules/Orchard.Fields

View File

@@ -36,7 +36,7 @@ namespace Orchard.ContentManagement {
return _session;
}
IQueryOver<ContentItemVersionRecord, TRecord> BindQueryOverByPath<TRecord, TU>(IQueryOver<ContentItemVersionRecord, TU> queryOver, string name) {
IQueryOver<ContentItemVersionRecord, TRecord> BindQueryOverByPath<TRecord, TU>(IQueryOver<ContentItemVersionRecord, TU> queryOver, string name, JoinType joinType = JoinType.InnerJoin) {
if (_joins.ContainsKey(typeof(TRecord).Name)) {
return (IQueryOver<ContentItemVersionRecord, TRecord>)_joins[typeof(TRecord).Name];
}
@@ -53,7 +53,7 @@ namespace Orchard.ContentManagement {
Expression.Property(parameter, syntheticProperty),
parameter);
var join = queryOver.JoinQueryOver(syntheticExpression);
var join = queryOver.JoinQueryOver(syntheticExpression, joinType);
_joins[typeof(TRecord).Name] = join;
return join;
@@ -62,13 +62,13 @@ namespace Orchard.ContentManagement {
IQueryOver<ContentItemVersionRecord, ContentTypeRecord> BindTypeQueryOver() {
// ([ContentItemVersionRecord] >join> [ContentItemRecord]) >join> [ContentType]
return BindQueryOverByPath<ContentTypeRecord, ContentItemRecord>(BindItemQueryOver(), "ContentType");
return BindQueryOverByPath<ContentTypeRecord, ContentItemRecord>(BindItemQueryOver(), "ContentType", JoinType.LeftOuterJoin);
}
IQueryOver<ContentItemVersionRecord, ContentItemRecord> BindItemQueryOver() {
// [ContentItemVersionRecord] >join> [ContentItemRecord]
return BindQueryOverByPath<ContentItemRecord, ContentItemVersionRecord>(BindItemVersionQueryOver(), "ContentItemRecord");
return BindQueryOverByPath<ContentItemRecord, ContentItemVersionRecord>(BindItemVersionQueryOver(), "ContentItemRecord", JoinType.LeftOuterJoin);
}
IQueryOver<ContentItemVersionRecord, ContentItemVersionRecord> BindItemVersionQueryOver() {
@@ -146,10 +146,12 @@ namespace Orchard.ContentManagement {
queryOver.Take(count);
}
return new ReadOnlyCollection<ContentItem>(queryOver
var result = queryOver
.List<ContentItemVersionRecord>()
.Select(x => ContentManager.Get(x.Id, VersionOptions.VersionRecord(x.Id)))
.ToList());
.ToList();
return new ReadOnlyCollection<ContentItem>(result);
}
int Count() {
@@ -291,6 +293,8 @@ namespace Orchard.ContentManagement {
.GroupBy(item => item.Segments.FirstOrDefault())
.ToDictionary(grouping => grouping.Key, StringComparer.InvariantCultureIgnoreCase);
var aggregatedProperty = false;
// locate hints that match properties in the ContentItemVersionRecord
foreach (var hit in contentItemVersionMetadata.PropertyNames.Where(hintDictionary.ContainsKey).SelectMany(key => hintDictionary[key])) {
contentItemVersionCriteria.UnderlyingCriteria.SetFetchMode(hit.Hint, FetchMode.Eager);
@@ -303,7 +307,7 @@ namespace Orchard.ContentManagement {
hit.Segments.Take(hit.Segments.Count() - 1).Aggregate(contentItemCriteria.UnderlyingCriteria, ExtendCriteria);
}
// if (hintDictionary.SelectMany(x => x.Value).Any(x => x.Segments.Count() > 1))
if (hintDictionary.SelectMany(x => x.Value).Any(x => x.Segments.Count() > 1))
contentItemVersionCriteria.TransformUsing(new DistinctRootEntityResultTransformer());
return this;

View File

@@ -23,7 +23,7 @@ namespace Orchard.Data.Conventions {
}
public void Apply(IOneToManyCollectionInstance instance) {
instance.Fetch.Join();
instance.Fetch.Select();
instance.Cache.ReadWrite();
}