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 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(); }