本文整理汇总了C#中EntityManager.AcceptChanges方法的典型用法代码示例。如果您正苦于以下问题:C# EntityManager.AcceptChanges方法的具体用法?C# EntityManager.AcceptChanges怎么用?C# EntityManager.AcceptChanges使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityManager
的用法示例。
在下文中一共展示了EntityManager.AcceptChanges方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExpImpWithNulls
public async Task ExpImpWithNulls() {
var em1 = await TestFns.NewEm(_serviceName);
var queryOptions = new QueryOptions(FetchStrategy.FromServer, MergeStrategy.OverwriteChanges);
var q0 = new EntityQuery<Customer>().Where(c => c.CompanyName != null && c.City != null)
.With(MergeStrategy.OverwriteChanges);
var r0 = (await em1.ExecuteQuery(q0)).ToList();
Assert.IsTrue(r0.Count > 2);
r0[0].CompanyName = null;
r0[1].City = null;
var exportedEntities = em1.ExportEntities(null, false);
var em2 = new EntityManager(em1);
em2.ImportEntities(exportedEntities);
var ek0 = r0[0].EntityAspect.EntityKey;
var ek1 = r0[1].EntityAspect.EntityKey;
var e0 = em2.FindEntityByKey<Customer>(ek0);
Assert.IsTrue(e0.CompanyName == null, "company name should be null");
Assert.IsTrue(e0.EntityAspect.EntityState.IsModified());
var e1 = em2.FindEntityByKey<Customer>(ek1);
Assert.IsTrue(e1.City == null, "city should be null");
Assert.IsTrue(e1.EntityAspect.EntityState.IsModified());
em2.AcceptChanges();
var exportedEntities2 = em2.ExportEntities(null, false);
em1.ImportEntities(exportedEntities2, new ImportOptions(MergeStrategy.OverwriteChanges));
Assert.IsTrue(em1.GetChanges().Count() == 0);
}