Exemplo n.º 1
0
 public IEnumerable <EntityReference> GetChildSnapshotReferences <TChildSnapshot>(string parentType, string parentId) where TChildSnapshot : EntitySnapshot
 {
     using (GetContext(out SqliteContext context))
     {
         var    snapshotSet = context.GetSnapshotSet <TChildSnapshot>();
         string childType   = EntityTypeLookups.GetEntityType(typeof(TChildSnapshot)).Name;
         return(snapshotSet.Where(e => e.Parent.EntityType == parentType && e.Parent.EntityID == parentId)
                .Select(e => e.EntityID)
                .ToList()
                .Select(id => new EntityReference(childType, id)));
     }
 }
Exemplo n.º 2
0
        public IEnumerable <EntityReference> GetSnapshotReferencesByParent(string parentType, string parentId)
        {
            ParentKey parentKey = new ParentKey(parentType, parentId);

            List <TSnapshot> childSnapshot = null;

            if (_parentMap.TryGetValue(parentKey, out childSnapshot))
            {
                foreach (var snapshot in childSnapshot)
                {
                    yield return(new EntityReference(EntityTypeLookups.GetEntityType(typeof(TSnapshot)).Name, snapshot.EntityID));
                }
            }
        }
Exemplo n.º 3
0
 public void StoreSnapshots(IEnumerable <EntitySnapshot> snapshots)
 {
     if (_isBatching)
     {
         foreach (var snapshot in snapshots)
         {
             EntityTypeLookups.StoreSnapshot(this, snapshot);
         }
     }
     else
     {
         using (GetContext(out SqliteContext context))
         {
             StoreSnapshotsImpl(context, snapshots);
             context.SaveChanges();
         }
     }
 }
Exemplo n.º 4
0
 private void UpdateModelState(List <EventSaveInfo> changes)
 {
     using (StartUpdateBatch(true))
     {
         foreach (var change in changes)
         {
             change.EventSavedCallback(change);
             if (change.NeedsAttach)
             {
                 AttachToModel(change.Entity);
             }
             var changeSnapshots = change.GetSnapshots();
             if (changeSnapshots != null)
             {
                 foreach (var changeSnapshot in changeSnapshots)
                 {
                     EntityTypeLookups.StoreSnapshot(BudgetStore.SnapshotStore, changeSnapshot);
                 }
             }
             InternalMessageBus.PublishEvent(change.Event.EntityType, change.Event);
             MessageBus.PublishEvent(change.Event.EntityType, change.Event);
         }
     }
 }