当前位置: 首页>>代码示例>>C#>>正文


C# EntityManager.NewIsLoadingBlock方法代码示例

本文整理汇总了C#中EntityManager.NewIsLoadingBlock方法的典型用法代码示例。如果您正苦于以下问题:C# EntityManager.NewIsLoadingBlock方法的具体用法?C# EntityManager.NewIsLoadingBlock怎么用?C# EntityManager.NewIsLoadingBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EntityManager的用法示例。


在下文中一共展示了EntityManager.NewIsLoadingBlock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessSaveResult

    private SaveResult ProcessSaveResult(EntityManager entityManager, SaveOptions saveOptions, JNode jNode) {

      var kms = jNode.GetArray<KeyMapping>("KeyMappings");
      var keyMappings = kms.Select(km => ToEntityKeys(km, entityManager.MetadataStore)).ToDictionary(tpl => tpl.Item1, tpl => tpl.Item2);
      using (entityManager.NewIsLoadingBlock(false)) {
        keyMappings.ForEach(km => {
          var targetEntity = entityManager.GetEntityByKey(km.Key);
          targetEntity.EntityAspect.SetDpValue(km.Key.EntityType.KeyProperties[0], km.Value.Values[0]);
        });

        var entityNodes = jNode.GetToken<JArray>("Entities");

        var serializer = new JsonSerializer();
        var mappingContext = new MappingContext() {
          EntityManager = entityManager,
          MergeStrategy = MergeStrategy.OverwriteChanges,
          LoadingOperation = LoadingOperation.Save,
          JsonResultsAdapter = saveOptions.DataService.JsonResultsAdapter
        };
        var jsonConverter = new JsonEntityConverter(mappingContext);
        serializer.Converters.Add(jsonConverter);
        // serializer.Converters.Add(new StringEnumConverter());
        // Don't use the result of the Deserialize call to get the list of entities 
        // because it won't include entities added on the server.
        serializer.Deserialize<IEnumerable<IEntity>>(entityNodes.CreateReader());
        var allEntities = mappingContext.Entities;
        allEntities.ForEach(e => e.EntityAspect.AcceptChanges());
        return new SaveResult(allEntities, keyMappings);
      }

    }
开发者ID:novice3030,项目名称:breeze.sharp,代码行数:31,代码来源:DataServiceAdapter.WebApi.cs

示例2: ProcessSaveResult

    private SaveResult ProcessSaveResult(EntityManager entityManager, string saveResultJson) {

      var jo = JObject.Parse(saveResultJson);

      var jn = new JNode(jo);
      var kms = jn.GetArray<KeyMapping>("KeyMappings");
      var keyMappings = kms.Select(km => ToEntityKeys(km)).ToDictionary(tpl => tpl.Item1, tpl => tpl.Item2);
      using (entityManager.NewIsLoadingBlock(false)) {
        keyMappings.ForEach(km => {
          var targetEntity = entityManager.FindEntityByKey(km.Key);
          targetEntity.EntityAspect.SetDpValue(km.Key.EntityType.KeyProperties[0], km.Value.Values[0]);
        });

        var prop = jo.Property("Entities");
        if (prop == null) return null;
        var entityNodes = (JArray)prop.Value;
        var serializer = new JsonSerializer();
        var jsonConverter = new JsonEntityConverter(entityManager, MergeStrategy.OverwriteChanges, NormalizeEntityTypeName);
        serializer.Converters.Add(jsonConverter);
        // Don't use the result of the Deserialize call to get the list of entities 
        // because it won't include entities added on the server.
        serializer.Deserialize<IEnumerable<IEntity>>(entityNodes.CreateReader());
        var allEntities = jsonConverter.AllEntities;
        allEntities.ForEach(e => e.EntityAspect.AcceptChanges());
        return new SaveResult(allEntities, keyMappings);
      }

    }
开发者ID:CodeLancer,项目名称:Breeze,代码行数:28,代码来源:DataServiceAdapter.WebApi.cs


注:本文中的EntityManager.NewIsLoadingBlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。