public void BeforeSave() { SaveMap = new Dictionary <Type, List <EntityInfo> >(); EntitiesWithAutoGeneratedKeys = new List <EntityInfo>(); EntityInfoGroups.ForEach(eg => { var entityInfos = eg.EntityInfos.Where(ei => ContextProvider.BeforeSaveEntity(ei)).ToList(); EntitiesWithAutoGeneratedKeys.AddRange(entityInfos.Where(ei => ei.AutoGeneratedKey != null)); SaveMap.Add(eg.EntityType, entityInfos); }); SaveMap = ContextProvider.BeforeSaveEntities(SaveMap); }
public void BeforeSave() { SaveMap = new Dictionary <Type, List <EntityInfo> >(); EntityInfoGroups.ForEach(eg => { var entityInfos = eg.EntityInfos.Where(ei => ContextProvider.BeforeSaveEntity(ei)).ToList(); SaveMap.Add(eg.EntityType, entityInfos); }); SaveMap = ContextProvider.BeforeSaveEntities(SaveMap); EntitiesWithAutoGeneratedKeys = SaveMap .SelectMany(eiGrp => eiGrp.Value) .Where(ei => ei.AutoGeneratedKey != null && ei.EntityState != EntityState.Detached) .ToList(); }
public SaveWorkState(ContextProvider contextProvider, JArray entitiesArray) { ContextProvider = contextProvider; var jObjects = entitiesArray.Select(jt => (dynamic)jt).ToList(); var groups = jObjects.GroupBy(jo => (String)jo.entityAspect.entityTypeName).ToList(); EntityInfoGroups = groups.Select(g => { var entityType = ContextProvider.LookupEntityType(g.Key); var entityInfos = g.Select(jo => ContextProvider.CreateEntityInfoFromJson(jo, entityType)).Cast <EntityInfo>().ToList(); return(new EntityGroup() { EntityType = entityType, EntityInfos = entityInfos }); }).ToList(); }
public async Task BeforeSaveAsync(CancellationToken cancellationToken) { SaveMap = new Dictionary <Type, List <EntityInfo> >(); foreach (var eg in EntityInfoGroups) { var entityInfos = new List <EntityInfo>(); foreach (var ei in eg.EntityInfos) { if (ContextProvider.BeforeSaveEntity(ei) && await ContextProvider.BeforeSaveEntityAsync(ei, cancellationToken)) { entityInfos.Add(ei); } } SaveMap.Add(eg.EntityType, entityInfos); } SaveMap = await ContextProvider.BeforeSaveEntitiesAsync(ContextProvider.BeforeSaveEntities(SaveMap), cancellationToken); EntitiesWithAutoGeneratedKeys = SaveMap .SelectMany(eiGrp => eiGrp.Value) .Where(ei => ei.AutoGeneratedKey != null && ei.EntityState != EntityState.Detached) .ToList(); }
/// <summary> /// Create a new instance. /// </summary> /// <param name="contextProvider">Used for getting entity keys for building EntityError objects.</param> public DataAnnotationsValidator(ContextProvider contextProvider) { this._contextProvider = contextProvider; }
public void AfterSave() { ContextProvider.AfterSaveEntities(SaveMap, KeyMappings); }
/// <summary> /// Create a new instance. /// </summary> /// <param name="contextProvider">Used for getting entity keys for building EntityError objects.</param> /// <param name="breezeMetadata">Contains breeze metadata. The structuralTypeList is extracted from it.</param> public BreezeMetadataValidator(ContextProvider contextProvider, IDictionary<string, object> breezeMetadata) { this._contextProvider = contextProvider; var structuralTypeList = (List<Dictionary<string, object>>) breezeMetadata["structuralTypes"]; this._structuralTypeMap = BuildStructuralTypeMap(structuralTypeList); }
/// <summary> /// Create a new instance. /// </summary> /// <param name="contextProvider">Used for getting entity keys for building EntityError objects.</param> /// <param name="structuralTypeList">Contains the validator information for properties of entity and complex types.</param> public BreezeMetadataValidator(ContextProvider contextProvider, List<Dictionary<string, object>> structuralTypeList) { this._contextProvider = contextProvider; this._structuralTypeMap = BuildStructuralTypeMap(structuralTypeList); }
/// <summary> /// Create a new instance. /// </summary> /// <param name="contextProvider">Used for getting entity keys for building EntityError objects.</param> /// <param name="structuralTypeList">Contains the validator information for properties of entity and complex types.</param> public BreezeMetadataValidator(ContextProvider contextProvider, List <Dictionary <string, object> > structuralTypeList) { this._contextProvider = contextProvider; this._structuralTypeMap = BuildStructuralTypeMap(structuralTypeList); }
public SaveWorkState(ContextProvider contextProvider, JArray entitiesArray) { ContextProvider = contextProvider; var jObjects = entitiesArray.Select(jt => (dynamic)jt).ToList(); var groups = jObjects.GroupBy(jo => (String)jo.entityAspect.entityTypeName).ToList(); EntityInfoGroups = groups.Select(g => { var entityType = ContextProvider.LookupEntityType(g.Key); var entityInfos = g.Select(jo => ContextProvider.CreateEntityInfoFromJson(jo, entityType)).Cast<EntityInfo>().ToList(); return new EntityGroup() { EntityType = entityType, EntityInfos = entityInfos }; }).ToList(); }
public Task AfterSaveAsync(CancellationToken cancellationToken) { ContextProvider.AfterSaveEntities(SaveMap, KeyMappings); return(ContextProvider.AfterSaveEntitiesAsync(SaveMap, KeyMappings, cancellationToken)); }