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


C# FixupContext.Entry方法代码示例

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


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

示例1: Add_dependent_then_principal_one_to_many_FK_set_no_navs_set

        public void Add_dependent_then_principal_one_to_many_FK_set_no_navs_set(EntityState entityState)
        {
            using (var context = new FixupContext())
            {
                var principal = new Category { Id = 77 };
                var dependent = new Product { Id = 78, CategoryId = principal.Id };

                context.Entry(dependent).State = entityState;
                context.Entry(principal).State = entityState;

                Assert.Equal(principal.Id, dependent.CategoryId);
                Assert.Same(principal, dependent.Category);
                Assert.Equal(new[] { dependent }.ToList(), principal.Products);
                Assert.Equal(entityState, context.Entry(principal).State);
                Assert.Equal(entityState, context.Entry(dependent).State);
            }
        }
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:17,代码来源:FixupTest.cs

示例2: Add_dependent_then_principal_one_to_many_FK_set_both_navs_set

        public void Add_dependent_then_principal_one_to_many_FK_set_both_navs_set(EntityState entityState)
        {
            using (var context = new FixupContext())
            {
                var principal = new Category { Id = 77 };
                var dependent = new Product { Id = 78, Category = principal };
                principal.Products.Add(dependent);

                context.Entry(dependent).Property("CategoryId").CurrentValue = principal.Id;

                context.Entry(dependent).State = entityState;
                context.Entry(principal).State = entityState;

                AssertFixup(
                    context,
                    () =>
                        {
                            Assert.Equal(principal.Id, context.Entry(dependent).Property("CategoryId").CurrentValue);
                            Assert.Same(principal, dependent.Category);
                            Assert.Equal(new[] { dependent }.ToList(), principal.Products);
                            Assert.Equal(entityState, context.Entry(principal).State);
                            Assert.Equal(entityState, context.Entry(dependent).State);
                        });
            }
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:25,代码来源:ShadowFkFixupTest.cs

示例3: Add_principal_then_dependent_one_to_many_no_navs_FK_set_no_navs_set

        public void Add_principal_then_dependent_one_to_many_no_navs_FK_set_no_navs_set(EntityState entityState)
        {
            using (var context = new FixupContext())
            {
                var principal = new CategoryNN { Id = 77 };
                var dependent = new ProductNN { Id = 78, CategoryId = principal.Id };

                context.Entry(principal).State = entityState;
                context.Entry(dependent).State = entityState;

                Assert.Equal(principal.Id, dependent.CategoryId);
                Assert.Equal(entityState, context.Entry(principal).State);
                Assert.Equal(entityState, context.Entry(dependent).State);
            }
        }
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:15,代码来源:FixupTest.cs

示例4: Add_dependent_then_principal_one_to_many_dep_uni_FK_not_set_dependent_nav_set

        public void Add_dependent_then_principal_one_to_many_dep_uni_FK_not_set_dependent_nav_set(EntityState entityState)
        {
            using (var context = new FixupContext())
            {
                var principal = new CategoryDN { Id = 77 };
                var dependent = new ProductDN { Id = 78, Category = principal };

                context.Entry(dependent).State = entityState;
                context.Entry(principal).State = entityState;

                Assert.Equal(principal.Id, dependent.CategoryId);
                Assert.Same(principal, dependent.Category);
                Assert.Equal(entityState, context.Entry(principal).State);
                Assert.Equal(entityState, context.Entry(dependent).State);
            }
        }
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:16,代码来源:FixupTest.cs

示例5: Add_principal_then_dependent_one_to_many_prin_uni_FK_not_set_principal_nav_set

        public void Add_principal_then_dependent_one_to_many_prin_uni_FK_not_set_principal_nav_set(EntityState entityState)
        {
            using (var context = new FixupContext())
            {
                var principal = new CategoryPN { Id = 77 };
                var dependent = new ProductPN { Id = 78 };
                principal.Products.Add(dependent);

                context.Entry(principal).State = entityState;
                context.Entry(dependent).State = entityState;

                Assert.Equal(principal.Id, dependent.CategoryId);
                Assert.Equal(new[] { dependent }.ToList(), principal.Products);
                Assert.Equal(entityState, context.Entry(principal).State);
                Assert.Equal(entityState, context.Entry(dependent).State);
            }
        }
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:17,代码来源:FixupTest.cs

示例6: Add_dependent_then_principal_one_to_one_no_navs_FK_set_no_navs_set

        public void Add_dependent_then_principal_one_to_one_no_navs_FK_set_no_navs_set(EntityState entityState)
        {
            using (var context = new FixupContext())
            {
                var principal = new ParentNN { Id = 77 };
                var dependent = new ChildNN { Id = 78, ParentId = principal.Id };

                context.Entry(dependent).State = entityState;
                context.Entry(principal).State = entityState;

                Assert.Equal(principal.Id, dependent.ParentId);
                Assert.Equal(entityState, context.Entry(principal).State);
                Assert.Equal(entityState, context.Entry(dependent).State);
            }
        }
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:15,代码来源:FixupTest.cs

示例7: Add_dependent_then_principal_one_to_one_FK_not_set_principal_nav_set

        public void Add_dependent_then_principal_one_to_one_FK_not_set_principal_nav_set(EntityState entityState)
        {
            using (var context = new FixupContext())
            {
                var principal = new Parent { Id = 77 };
                var dependent = new Child { Id = 78 };
                principal.Child = dependent;

                context.Entry(dependent).State = entityState;
                context.Entry(principal).State = entityState;

                AssertFixup(
                    context,
                    () =>
                        {
                            Assert.Equal(principal.Id, context.Entry(dependent).Property("ParentId").CurrentValue);
                            Assert.Same(principal, dependent.Parent);
                            Assert.Same(dependent, principal.Child);
                            Assert.Equal(entityState, context.Entry(principal).State);
                            Assert.Equal(entityState, context.Entry(dependent).State);
                        });
            }
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:23,代码来源:ShadowFkFixupTest.cs

示例8: Add_principal_but_not_dependent_one_to_many_prin_uni_FK_not_set_principal_nav_set

        public void Add_principal_but_not_dependent_one_to_many_prin_uni_FK_not_set_principal_nav_set(EntityState entityState)
        {
            using (var context = new FixupContext())
            {
                var principal = new CategoryPN { Id = 77 };
                var dependent = new ProductPN { Id = 78 };

                context.Entry(principal).State = entityState;

                principal.Products.Add(dependent);

                context.ChangeTracker.DetectChanges();

                AssertFixup(
                    context,
                    () =>
                        {
                            Assert.Equal(principal.Id, dependent.CategoryId);
                            Assert.Equal(new[] { dependent }.ToList(), principal.Products);
                            Assert.Equal(entityState, context.Entry(principal).State);
                            Assert.Equal(EntityState.Added, context.Entry(dependent).State);
                        });
            }
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:24,代码来源:FixupTest.cs

示例9: Add_principal_then_dependent_one_to_one_dep_uni_FK_set_dependent_nav_set

        public void Add_principal_then_dependent_one_to_one_dep_uni_FK_set_dependent_nav_set(EntityState entityState)
        {
            using (var context = new FixupContext())
            {
                var principal = new ParentDN { Id = 77 };
                var dependent = new ChildDN { Id = 78, Parent = principal };

                context.Entry(dependent).Property("ParentId").CurrentValue = principal.Id;

                context.Entry(principal).State = entityState;
                context.Entry(dependent).State = entityState;

                AssertFixup(
                    context,
                    () =>
                        {
                            Assert.Equal(principal.Id, context.Entry(dependent).Property("ParentId").CurrentValue);
                            Assert.Same(principal, dependent.Parent);
                            Assert.Equal(entityState, context.Entry(principal).State);
                            Assert.Equal(entityState, context.Entry(dependent).State);
                        });
            }
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:23,代码来源:ShadowFkFixupTest.cs

示例10: Add_dependent_but_not_principal_one_to_one_dep_uni_FK_not_set_dependent_nav_set

        public void Add_dependent_but_not_principal_one_to_one_dep_uni_FK_not_set_dependent_nav_set(EntityState entityState)
        {
            using (var context = new FixupContext())
            {
                var principal = new ParentDN { Id = 77 };
                var dependent = new ChildDN { Id = 78 };

                context.Entry(dependent).State = entityState;

                dependent.Parent = principal;

                context.ChangeTracker.DetectChanges();

                AssertFixup(
                    context,
                    () =>
                        {
                            Assert.Equal(principal.Id, dependent.ParentId);
                            Assert.Same(principal, dependent.Parent);
                            Assert.Equal(EntityState.Added, context.Entry(principal).State);
                            Assert.Equal(entityState == EntityState.Added ? EntityState.Added : EntityState.Modified, context.Entry(dependent).State);
                        });
            }
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:24,代码来源:FixupTest.cs

示例11: Add_principal_but_not_dependent_one_to_one_no_navs_FK_set_no_navs_set

        public void Add_principal_but_not_dependent_one_to_one_no_navs_FK_set_no_navs_set(EntityState entityState)
        {
            using (var context = new FixupContext())
            {
                var principal = new ParentNN { Id = 77 };
                var dependent = new ChildNN { Id = 78 };

                context.Entry(principal).State = entityState;

                dependent.ParentId = principal.Id;

                context.ChangeTracker.DetectChanges();

                AssertFixup(
                    context,
                    () =>
                        {
                            Assert.Equal(principal.Id, dependent.ParentId);
                            Assert.Equal(entityState, context.Entry(principal).State);
                            Assert.Equal(EntityState.Detached, context.Entry(dependent).State);
                        });
            }
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:23,代码来源:FixupTest.cs

示例12: Add_principal_but_not_dependent_one_to_one_prin_uni_FK_not_set_principal_nav_set

        public void Add_principal_but_not_dependent_one_to_one_prin_uni_FK_not_set_principal_nav_set(EntityState entityState)
        {
            using (var context = new FixupContext())
            {
                var principal = new ParentPN { Id = 77 };
                var dependent = new ChildPN { Id = 78 };

                context.Entry(principal).State = entityState;

                principal.Child = dependent;

                context.ChangeTracker.DetectChanges();

                AssertFixup(
                    context,
                    () =>
                        {
                            Assert.Equal(principal.Id, dependent.ParentId);
                            Assert.Same(dependent, principal.Child);
                            Assert.Equal(entityState, context.Entry(principal).State);
                            Assert.Equal(EntityState.Added, context.Entry(dependent).State);
                        });
            }
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:24,代码来源:FixupTest.cs

示例13: Add_dependent_but_not_principal_one_to_many_no_navs_FK_set_no_navs_set

        public void Add_dependent_but_not_principal_one_to_many_no_navs_FK_set_no_navs_set(EntityState entityState)
        {
            using (var context = new FixupContext())
            {
                var principal = new CategoryNN { Id = 77 };
                var dependent = new ProductNN { Id = 78 };

                context.Entry(dependent).State = entityState;

                dependent.CategoryId = principal.Id;

                context.ChangeTracker.DetectChanges();

                AssertFixup(
                    context,
                    () =>
                        {
                            Assert.Equal(principal.Id, dependent.CategoryId);
                            Assert.Equal(EntityState.Detached, context.Entry(principal).State);
                            Assert.Equal(entityState == EntityState.Added ? EntityState.Added : EntityState.Modified, context.Entry(dependent).State);
                        });
            }
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:23,代码来源:FixupTest.cs

示例14: Add_principal_but_not_dependent_one_to_many_dep_uni_FK_not_set_dependent_nav_set

        public void Add_principal_but_not_dependent_one_to_many_dep_uni_FK_not_set_dependent_nav_set(EntityState entityState)
        {
            using (var context = new FixupContext())
            {
                var principal = new CategoryDN { Id = 77 };
                var dependent = new ProductDN { Id = 78 };

                context.Entry(principal).State = entityState;

                dependent.Category = principal;

                context.ChangeTracker.DetectChanges();

                AssertFixup(
                    context,
                    () =>
                        {
                            Assert.Equal(0, dependent.CategoryId);
                            Assert.Same(principal, dependent.Category);
                            Assert.Equal(entityState, context.Entry(principal).State);
                            Assert.Equal(EntityState.Detached, context.Entry(dependent).State);
                        });
            }
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:24,代码来源:FixupTest.cs

示例15: Add_principal_then_dependent_one_to_one_FK_not_set_dependent_nav_set

        public void Add_principal_then_dependent_one_to_one_FK_not_set_dependent_nav_set(EntityState entityState)
        {
            using (var context = new FixupContext())
            {
                var principal = new Parent { Id = 77 };
                var dependent = new Child { Id = 78, Parent = principal };

                context.Entry(principal).State = entityState;
                context.Entry(dependent).State = entityState;

                Assert.Equal(principal.Id, dependent.ParentId);
                Assert.Same(principal, dependent.Parent);
                Assert.Same(dependent, principal.Child);
                Assert.Equal(entityState, context.Entry(principal).State);
                Assert.Equal(entityState, context.Entry(dependent).State);
            }
        }
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:17,代码来源:FixupTest.cs


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