本文整理汇总了C#中SimpleModel.SimpleModelContext.Entry方法的典型用法代码示例。如果您正苦于以下问题:C# SimpleModelContext.Entry方法的具体用法?C# SimpleModelContext.Entry怎么用?C# SimpleModelContext.Entry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleModel.SimpleModelContext
的用法示例。
在下文中一共展示了SimpleModelContext.Entry方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DbEntityEntry_Member_works_for_collections_under_partial_trust
public void DbEntityEntry_Member_works_for_collections_under_partial_trust()
{
using (var context = new SimpleModelContext())
{
var category = context.Categories.First();
var collection = context.Entry(category).Member<ICollection<Product>>("Products");
Assert.NotNull(collection);
Assert.IsType<DbCollectionEntry<Category, Product>>(collection);
}
}
示例2: using
public void Setting_current_value_of_reference_nav_prop_to_null_does_nothing_for_an_FK_relationship_if_the_relationship_is_not_loaded_and_legacy_behavior_is_set_on_ObjectContext()
{
using (var context = new SimpleModelContext())
{
context.Configuration.LazyLoadingEnabled = false;
((IObjectContextAdapter)context).ObjectContext.ContextOptions.UseConsistentNullReferenceBehavior = false;
var product = context.Products.Find(1);
Assert.NotNull(product.CategoryId);
Assert.Null(product.Category);
context.Entry(product).Reference(p => p.Category).CurrentValue = null;
Assert.NotNull(product.CategoryId);
Assert.Null(product.Category);
}
}
示例3: Setting_current_value_of_reference_nav_prop_works_under_partial_trust
public void Setting_current_value_of_reference_nav_prop_works_under_partial_trust()
{
using (var context = new SimpleModelContext())
{
var product = context.Products.Find(1);
Assert.Null(product.Category);
var newCategory = new Category("BeanBags");
context.Entry(product).Reference(p => p.Category).CurrentValue = newCategory;
Assert.Equal("BeanBags", product.CategoryId);
Assert.Same(newCategory, product.Category);
}
}