本文整理汇总了C#中TestDbContext.Entry方法的典型用法代码示例。如果您正苦于以下问题:C# TestDbContext.Entry方法的具体用法?C# TestDbContext.Entry怎么用?C# TestDbContext.Entry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestDbContext
的用法示例。
在下文中一共展示了TestDbContext.Entry方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldSupportNullValuesInTree
public void ShouldSupportNullValuesInTree()
{
var node1 = new TestNode
{
Title = "New Node",
OneToOneOwned = null
};
using (var context = new TestDbContext())
{
context.Nodes.Add(node1);
context.SaveChanges();
} // Simulate detach
using (var context = new TestDbContext())
{
// Setup mapping
node1 = context.UpdateGraph(node1, map => map
.OwnedEntity(p => p.OneToOneOwned, with =>
with.OwnedEntity(p => p.OneToOneOneToOneOwned)));
context.SaveChanges();
context.Entry(node1).Reload();
Assert.IsTrue(node1.OneToOneOwned == null);
}
}
示例2: ShouldSupportMultipleKeys
public void ShouldSupportMultipleKeys()
{
var model = new MultiKeyModel
{
Title = "Hello",
Date = DateTime.Now,
KeyPart1 = "A123",
KeyPart2 = "A234"
};
using (var context = new TestDbContext())
{
context.MultiKeyModels.Add(model);
context.SaveChanges();
} // simulate detach
model.Date = DateTime.Parse("01/01/2010");
using (var context = new TestDbContext())
{
model = context.UpdateGraph(model);
context.SaveChanges();
context.Entry(model).Reload();
Assert.IsTrue(model.Date == DateTime.Parse("01/01/2010"));
}
}