• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# FixupContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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


示例2: Navigation_fixup_happens_when_new_entities_are_tracked

        public void Navigation_fixup_happens_when_new_entities_are_tracked()
        {
            using (var context = new FixupContext())
            {
                context.Add(new Category { Id = 11 });
                context.Add(new Category { Id = 12 });
                context.Add(new Category { Id = 13 });

                context.Add(new Product { Id = 21, CategoryId = 11 });
                AssertAllFixedUp(context);
                context.Add(new Product { Id = 22, CategoryId = 11 });
                AssertAllFixedUp(context);
                context.Add(new Product { Id = 23, CategoryId = 11 });
                AssertAllFixedUp(context);
                context.Add(new Product { Id = 24, CategoryId = 12 });
                AssertAllFixedUp(context);
                context.Add(new Product { Id = 25, CategoryId = 12 });
                AssertAllFixedUp(context);

                context.Add(new SpecialOffer { Id = 31, ProductId = 22 });
                AssertAllFixedUp(context);
                context.Add(new SpecialOffer { Id = 32, ProductId = 22 });
                AssertAllFixedUp(context);
                context.Add(new SpecialOffer { Id = 33, ProductId = 24 });
                AssertAllFixedUp(context);
                context.Add(new SpecialOffer { Id = 34, ProductId = 24 });
                AssertAllFixedUp(context);
                context.Add(new SpecialOffer { Id = 35, ProductId = 24 });
                AssertAllFixedUp(context);

                Assert.Equal(3, context.ChangeTracker.Entries<Category>().Count());
                Assert.Equal(5, context.ChangeTracker.Entries<Product>().Count());
                Assert.Equal(5, context.ChangeTracker.Entries<SpecialOffer>().Count());
            }
        }
开发者ID:491134648,项目名称:EntityFramework,代码行数:35,代码来源:FixupTest.cs


示例3: 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


示例4: Navigation_fixup_happens_when_entities_are_tracked_from_query

        public void Navigation_fixup_happens_when_entities_are_tracked_from_query()
        {
            using (var context = new FixupContext())
            {
                var categoryType = context.Model.GetEntityType(typeof(Category));
                var productType = context.Model.GetEntityType(typeof(Product));
                var offerType = context.Model.GetEntityType(typeof(SpecialOffer));

                var stateManager = context.ChangeTracker.GetService();

                stateManager.StartTracking(categoryType, new SimpleEntityKey<int>(categoryType.FindPrimaryKey(), 11), new Category { Id = 11 }, new ValueBuffer(new object[] { 11 }));
                stateManager.StartTracking(categoryType, new SimpleEntityKey<int>(categoryType.FindPrimaryKey(), 12), new Category { Id = 12 }, new ValueBuffer(new object[] { 12 }));
                stateManager.StartTracking(categoryType, new SimpleEntityKey<int>(categoryType.FindPrimaryKey(), 13), new Category { Id = 13 }, new ValueBuffer(new object[] { 13 }));

                stateManager.StartTracking(productType, new SimpleEntityKey<int>(productType.FindPrimaryKey(), 21), new Product { Id = 21, CategoryId = 11 }, new ValueBuffer(new object[] { 21, 11 }));
                AssertAllFixedUp(context);
                stateManager.StartTracking(productType, new SimpleEntityKey<int>(productType.FindPrimaryKey(), 22), new Product { Id = 22, CategoryId = 11 }, new ValueBuffer(new object[] { 22, 11 }));
                AssertAllFixedUp(context);
                stateManager.StartTracking(productType, new SimpleEntityKey<int>(productType.FindPrimaryKey(), 23), new Product { Id = 23, CategoryId = 11 }, new ValueBuffer(new object[] { 23, 11 }));
                AssertAllFixedUp(context);
                stateManager.StartTracking(productType, new SimpleEntityKey<int>(productType.FindPrimaryKey(), 24), new Product { Id = 24, CategoryId = 12 }, new ValueBuffer(new object[] { 24, 12 }));
                AssertAllFixedUp(context);
                stateManager.StartTracking(productType, new SimpleEntityKey<int>(productType.FindPrimaryKey(), 25), new Product { Id = 25, CategoryId = 12 }, new ValueBuffer(new object[] { 25, 12 }));
                AssertAllFixedUp(context);

                stateManager.StartTracking(offerType, new SimpleEntityKey<int>(offerType.FindPrimaryKey(), 31), new SpecialOffer { Id = 31, ProductId = 22 }, new ValueBuffer(new object[] { 31, 22 }));
                AssertAllFixedUp(context);
                stateManager.StartTracking(offerType, new SimpleEntityKey<int>(offerType.FindPrimaryKey(), 32), new SpecialOffer { Id = 32, ProductId = 22 }, new ValueBuffer(new object[] { 32, 22 }));
                AssertAllFixedUp(context);
                stateManager.StartTracking(offerType, new SimpleEntityKey<int>(offerType.FindPrimaryKey(), 33), new SpecialOffer { Id = 33, ProductId = 24 }, new ValueBuffer(new object[] { 33, 24 }));
                AssertAllFixedUp(context);
                stateManager.StartTracking(offerType, new SimpleEntityKey<int>(offerType.FindPrimaryKey(), 34), new SpecialOffer { Id = 34, ProductId = 24 }, new ValueBuffer(new object[] { 34, 24 }));
                AssertAllFixedUp(context);
                stateManager.StartTracking(offerType, new SimpleEntityKey<int>(offerType.FindPrimaryKey(), 35), new SpecialOffer { Id = 35, ProductId = 24 }, new ValueBuffer(new object[] { 35, 24 }));

                AssertAllFixedUp(context);

                Assert.Equal(3, context.ChangeTracker.Entries<Category>().Count());
                Assert.Equal(5, context.ChangeTracker.Entries<Product>().Count());
                Assert.Equal(5, context.ChangeTracker.Entries<SpecialOffer>().Count());
            }
        }
开发者ID:491134648,项目名称:EntityFramework,代码行数:42,代码来源:FixupTest.cs


示例5: Navigation_fixup_happens_when_entities_are_materialized

        public void Navigation_fixup_happens_when_entities_are_materialized()
        {
            using (var context = new FixupContext())
            {
                var categoryType = context.Model.GetEntityType(typeof(Category));
                var productType = context.Model.GetEntityType(typeof(Product));
                var offerType = context.Model.GetEntityType(typeof(SpecialOffer));

                var stateManager = context.ChangeTracker.StateManager;

                stateManager.GetOrMaterializeEntry(categoryType, new ObjectArrayValueReader(new object[] { 11 }));
                stateManager.GetOrMaterializeEntry(categoryType, new ObjectArrayValueReader(new object[] { 12 }));
                stateManager.GetOrMaterializeEntry(categoryType, new ObjectArrayValueReader(new object[] { 13 }));

                stateManager.GetOrMaterializeEntry(productType, new ObjectArrayValueReader(new object[] { 11, 21 }));
                AssertAllFixedUp(context);
                stateManager.GetOrMaterializeEntry(productType, new ObjectArrayValueReader(new object[] { 11, 22 }));
                AssertAllFixedUp(context);
                stateManager.GetOrMaterializeEntry(productType, new ObjectArrayValueReader(new object[] { 11, 23 }));
                AssertAllFixedUp(context);
                stateManager.GetOrMaterializeEntry(productType, new ObjectArrayValueReader(new object[] { 12, 24 }));
                AssertAllFixedUp(context);
                stateManager.GetOrMaterializeEntry(productType, new ObjectArrayValueReader(new object[] { 12, 25 }));
                AssertAllFixedUp(context);

                stateManager.GetOrMaterializeEntry(offerType, new ObjectArrayValueReader(new object[] { 31, 22 }));
                AssertAllFixedUp(context);
                stateManager.GetOrMaterializeEntry(offerType, new ObjectArrayValueReader(new object[] { 32, 22 }));
                AssertAllFixedUp(context);
                stateManager.GetOrMaterializeEntry(offerType, new ObjectArrayValueReader(new object[] { 33, 24 }));
                AssertAllFixedUp(context);
                stateManager.GetOrMaterializeEntry(offerType, new ObjectArrayValueReader(new object[] { 34, 24 }));
                AssertAllFixedUp(context);
                stateManager.GetOrMaterializeEntry(offerType, new ObjectArrayValueReader(new object[] { 35, 24 }));
                AssertAllFixedUp(context);

                Assert.Equal(3, context.ChangeTracker.Entries<Category>().Count());
                Assert.Equal(5, context.ChangeTracker.Entries<Product>().Count());
                Assert.Equal(5, context.ChangeTracker.Entries<SpecialOffer>().Count());
            }
        }
开发者ID:Nyaoso,项目名称:EntityFramework,代码行数:41,代码来源:FixupTest.cs


示例6: 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


示例7: 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


示例8: 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


示例9: 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


示例10: 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


示例11: 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


示例12: 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


示例13: Navigation_fixup_happens_when_entities_are_tracked_from_query

        public void Navigation_fixup_happens_when_entities_are_tracked_from_query()
        {
            using (var context = new FixupContext())
            {
                var categoryType = context.Model.FindEntityType(typeof(Category));
                var productType = context.Model.FindEntityType(typeof(Product));
                var offerType = context.Model.FindEntityType(typeof(SpecialOffer));

                var stateManager = context.ChangeTracker.GetInfrastructure();

                stateManager.BeginTrackingQuery();

                stateManager.StartTrackingFromQuery(categoryType, new Category { Id = 11 }, new ValueBuffer(new object[] { 11 }));
                stateManager.StartTrackingFromQuery(categoryType, new Category { Id = 12 }, new ValueBuffer(new object[] { 12 }));
                stateManager.StartTrackingFromQuery(categoryType, new Category { Id = 13 }, new ValueBuffer(new object[] { 13 }));

                stateManager.BeginTrackingQuery();

                stateManager.StartTrackingFromQuery(productType, new Product { Id = 21, CategoryId = 11 }, new ValueBuffer(new object[] { 21, 11 }));
                AssertAllFixedUp(context);
                stateManager.StartTrackingFromQuery(productType, new Product { Id = 22, CategoryId = 11 }, new ValueBuffer(new object[] { 22, 11 }));
                AssertAllFixedUp(context);
                stateManager.StartTrackingFromQuery(productType, new Product { Id = 23, CategoryId = 11 }, new ValueBuffer(new object[] { 23, 11 }));
                AssertAllFixedUp(context);
                stateManager.StartTrackingFromQuery(productType, new Product { Id = 24, CategoryId = 12 }, new ValueBuffer(new object[] { 24, 12 }));
                AssertAllFixedUp(context);
                stateManager.StartTrackingFromQuery(productType, new Product { Id = 25, CategoryId = 12 }, new ValueBuffer(new object[] { 25, 12 }));
                AssertAllFixedUp(context);

                stateManager.BeginTrackingQuery();

                stateManager.StartTrackingFromQuery(offerType, new SpecialOffer { Id = 31, ProductId = 22 }, new ValueBuffer(new object[] { 31, 22 }));
                AssertAllFixedUp(context);
                stateManager.StartTrackingFromQuery(offerType, new SpecialOffer { Id = 32, ProductId = 22 }, new ValueBuffer(new object[] { 32, 22 }));
                AssertAllFixedUp(context);
                stateManager.StartTrackingFromQuery(offerType, new SpecialOffer { Id = 33, ProductId = 24 }, new ValueBuffer(new object[] { 33, 24 }));
                AssertAllFixedUp(context);
                stateManager.StartTrackingFromQuery(offerType, new SpecialOffer { Id = 34, ProductId = 24 }, new ValueBuffer(new object[] { 34, 24 }));
                AssertAllFixedUp(context);
                stateManager.StartTrackingFromQuery(offerType, new SpecialOffer { Id = 35, ProductId = 24 }, new ValueBuffer(new object[] { 35, 24 }));

                AssertAllFixedUp(context);

                Assert.Equal(3, context.ChangeTracker.Entries<Category>().Count());
                Assert.Equal(5, context.ChangeTracker.Entries<Product>().Count());
                Assert.Equal(5, context.ChangeTracker.Entries<SpecialOffer>().Count());
            }
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:48,代码来源:FixupTest.cs


示例14: 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


示例15: 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


示例16: 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


示例17: 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


示例18: Add_dependent_then_principal_one_to_one_prin_uni_FK_set_principal_nav_set

        public void Add_dependent_then_principal_one_to_one_prin_uni_FK_set_principal_nav_set(EntityState entityState)
        {
            using (var context = new FixupContext())
            {
                var principal = new ParentPN { Id = 77 };
                var dependent = new ChildPN { Id = 78, ParentId = principal.Id };
                principal.Child = dependent;

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

                Assert.Equal(principal.Id, dependent.ParentId);
                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


示例19: 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


示例20: 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 };

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

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

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Flag类代码示例发布时间:2022-05-24
下一篇:
C# Fixture类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap