Breeze.ContextProvider.ContextProvider.CreateEntityInfoFromJson C# (CSharp) Method

CreateEntityInfoFromJson() protected method

protected CreateEntityInfoFromJson ( dynamic jo, Type entityType ) : EntityInfo
jo dynamic
entityType System.Type
return EntityInfo
    protected internal EntityInfo CreateEntityInfoFromJson(dynamic jo, Type entityType) {
      var entityInfo = CreateEntityInfo();

      entityInfo.Entity = JsonSerializer.Deserialize(new JTokenReader(jo), entityType);
      entityInfo.EntityState = (EntityState)Enum.Parse(typeof(EntityState), (String)jo.entityAspect.entityState);
      entityInfo.ContextProvider = this;


      entityInfo.UnmappedValuesMap = JsonToDictionary(jo.__unmapped);
      entityInfo.OriginalValuesMap = JsonToDictionary(jo.entityAspect.originalValuesMap);

      var autoGeneratedKey = jo.entityAspect.autoGeneratedKey;
      if (entityInfo.EntityState == EntityState.Added && autoGeneratedKey != null) {
        entityInfo.AutoGeneratedKey = new AutoGeneratedKey(entityInfo.Entity, autoGeneratedKey);
      }
      return entityInfo;
    }

Usage Example

コード例 #1
0
        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();
        }
All Usage Examples Of Breeze.ContextProvider.ContextProvider::CreateEntityInfoFromJson