本文整理汇总了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);
}
}
示例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);
}
}