Forráskód Böngészése

Changed an aggregate

Kenric Nugteren 7 hónapja
szülő
commit
0904badbf0
1 módosított fájl, 7 hozzáadás és 16 törlés
  1. 7 16
      prs.classes/Entities/Notification/Notification.cs

+ 7 - 16
prs.classes/Entities/Notification/Notification.cs

@@ -5,20 +5,6 @@ using InABox.Core;
 
 namespace Comal.Classes
 {
-
-    public class NotificationDocumentCount : CoreAggregate<Notification, NotificationDocument, Guid>
-    {
-        public override Expression<Func<NotificationDocument, Guid>> Aggregate => x => x.ID;
-
-        public override AggregateCalculation Calculation => AggregateCalculation.Count;
-
-        public override Dictionary<Expression<Func<NotificationDocument, object>>, Expression<Func<Notification, object>>> Links =>
-            new Dictionary<Expression<Func<NotificationDocument, object>>, Expression<Func<Notification, object>>>()
-            {
-                { NotificationDocument => NotificationDocument.EntityLink.ID, Notification => Notification.ID }
-            };
-    }
-    
     [UserTracking("Notifications")]
     public class Notification : Entity, IRemotable, IPersistent, IOneToMany<Job>, ILicense<CoreLicense>
     {
@@ -76,9 +62,14 @@ namespace Comal.Classes
 
         [NullEditor]
         public Guid EntityID { get; set; }
-        
+
+        private class DocumentCountFormula : ComplexFormulaGenerator<Notification, int>
+        {
+            public override IComplexFormulaNode<Notification, int> GetFormula() =>
+                Count<NotificationDocument, Guid>(x => x.Property(x => x.ID)).WithLink(x => x.EntityLink.ID, x => x.ID);
+        }
         [NullEditor]
-        [Aggregate(typeof(NotificationDocumentCount))]
+        [ComplexFormula(typeof(DocumentCountFormula))]
         public int DocumentCount { get; set; }
     }
 }