Breeze.Entities.BreezeEntityBuilder.BuildEntityGroups C# (CSharp) Method

BuildEntityGroups() protected method

Create EntityGroup objects from the raw entities sent by the client.
protected BuildEntityGroups ( List rawEntities ) : List
rawEntities List Objects assumed to have an entityAspect property containing the entityTypeName
return List
        protected List<EntityGroup> BuildEntityGroups(List<object> rawEntities)
        {
            var jObjects = rawEntities.Select(jt => (dynamic)jt).ToList();
            // group the objects by the entityTypeName
            var groups = jObjects.GroupBy(jo => (String)jo.entityAspect.entityTypeName).ToList();

            // create EntityGroup objects by looking up the entity type and creating the entity instances
            var entityInfoGroups = groups.Select(g => {
                var entityType = LookupEntityType(g.Key);
                var entityInfos = g.Select(jo => CreateEntityInfoFromJson(jo, entityType)).Cast<EntityInfo>().ToList();
                return new EntityGroup() { EntityType = entityType, EntityInfos = entityInfos };
            }).ToList();

            return entityInfoGroups;
        }