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

C# ConcurrencyModel.F1Context类代码示例

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

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



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

示例1: SetupContext

        private void SetupContext(F1Context context)
        {
            var drivers = context.Drivers;
            drivers.Load();

            foreach (var driver in drivers.Local.Where(d => d.TeamId == DeletedTeam).ToList())
            {
                drivers.Remove(driver);
            }

            foreach (var driver in drivers.Local.Where(d => d.TeamId == ModifedTeam).ToList())
            {
                driver.Races = 5;
            }

            drivers.Add(
                new Driver
                    {
                        Name = "Pedro de la Rosa",
                        TeamId = AddedTeam,
                        CarNumber = 13
                    });
            drivers.Add(
                new Driver
                    {
                        Name = "Kamui Kobayashi",
                        TeamId = AddedTeam,
                        CarNumber = null
                    });
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:30,代码来源:DatabindingTests.cs


示例2: Lazy_loading_entity_collection_works_on_modified_entity

        public void Lazy_loading_entity_collection_works_on_modified_entity()
        {
            using (var context = new F1Context())
            {
                var team = context.Teams.FirstOrDefault();
                team.Constructor = "Fooblearius Fooblebar";

                Assert.True(team.Drivers.Count > 0);
            }
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:10,代码来源:LazyLoadingTests.cs


示例3: Lazy_loading_entity_collection_does_not_work_on_deleted_entity

        public void Lazy_loading_entity_collection_does_not_work_on_deleted_entity()
        {
            using (var context = new F1Context())
            {
                var team = context.Teams.FirstOrDefault();
                var objectContext = ((IObjectContextAdapter)context).ObjectContext;
                objectContext.DeleteObject(team);

                Assert.Equal(0, team.Drivers.Count);
            }
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:11,代码来源:LazyLoadingTests.cs


示例4: Lazy_loading_of_entity_reference_does_not_work_on_detached_entity

        public void Lazy_loading_of_entity_reference_does_not_work_on_detached_entity()
        {
            using (var context = new F1Context())
            {
                var team = context.Teams.FirstOrDefault();
                var objectContext = ((IObjectContextAdapter)context).ObjectContext;
                objectContext.Detach(team);

                Assert.Null(team.Engine);
            }
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:11,代码来源:LazyLoadingTests.cs


示例5: Lazy_loading_of_entity_reference_works_on_modified_entity

        public void Lazy_loading_of_entity_reference_works_on_modified_entity()
        {
            using (var context = new F1Context())
            {
                var teamId = context.Teams.OrderBy(t => t.Id).AsNoTracking().FirstOrDefault().Id;
                var engineId = context.Teams.Where(t => t.Id == teamId).Select(t => t.Engine).AsNoTracking().FirstOrDefault().Id;

                var team = context.Teams.Where(t => t.Id == teamId).AsNoTracking().Single();
                team.Constructor = "Fooblearius Fooblebar";

                Assert.NotNull(team.Engine);
            }
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:13,代码来源:LazyLoadingTests.cs


示例6: DbSet_Local_contains_Unchanged_Modified_and_Added_entities_but_not_Deleted_entities_implementation

        private void DbSet_Local_contains_Unchanged_Modified_and_Added_entities_but_not_Deleted_entities_implementation(
            Func<F1Context, ObservableCollection<Driver>> getLocal)
        {
            using (var context = new F1Context())
            {
                SetupContext(context);
                var local = getLocal(context);

                Assert.Equal(0, local.Count(d => d.TeamId == DeletedTeam));
                Assert.Equal(ModifiedCount, local.Count(d => d.TeamId == ModifedTeam));
                Assert.Equal(UnchangedCount, local.Count(d => d.TeamId == UnchangedTeam));
                Assert.Equal(AddedCount, local.Count(d => d.TeamId == AddedTeam));
            }
        }
开发者ID:junxy,项目名称:entityframework,代码行数:14,代码来源:DatabindingTests.cs


示例7: Non_generic_collection_navigation_property_can_be_loaded_and_IsLoaded_is_set

        public void Non_generic_collection_navigation_property_can_be_loaded_and_IsLoaded_is_set()
        {
            using (var context = new F1Context())
            {
                context.Configuration.LazyLoadingEnabled = false;

                var team = context.Teams.Find(Team.McLaren);
                var driversCollection = context.Entry((object)team).Collection("Drivers");

                Assert.False(driversCollection.IsLoaded);
                driversCollection.Load();
                Assert.True(driversCollection.IsLoaded);
                Assert.Equal(3, team.Drivers.Count);
            }
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:15,代码来源:PropertyApiTests.cs


示例8: Non_generic_reference_navigation_property_can_be_loaded_and_IsLoaded_is_set

        public void Non_generic_reference_navigation_property_can_be_loaded_and_IsLoaded_is_set()
        {
            using (var context = new F1Context())
            {
                context.Configuration.LazyLoadingEnabled = false;

                var driver = context.Drivers.Single(d => d.Name == "Jenson Button");
                var teamReference = context.Entry((object)driver).Reference("Team");

                Assert.False(teamReference.IsLoaded);
                teamReference.Load();
                Assert.True(teamReference.IsLoaded);
                Assert.Equal(Team.McLaren, driver.Team.Id);
            }
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:15,代码来源:PropertyApiTests.cs


示例9: ValidateOnSaveEnabled_flag_is_on_by_default_when_using_ObjectContext_constructor

 public void ValidateOnSaveEnabled_flag_is_on_by_default_when_using_ObjectContext_constructor()
 {
     var objectContext = GetObjectContext(new F1Context());
     using (var context = new F1Context(objectContext, dbContextOwnsObjectContext: true))
     {
         Assert.True(context.Configuration.ValidateOnSaveEnabled);
     }
 }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:8,代码来源:DbContextTests.cs


示例10: ValidateOnSaveEnabled_is_on_by_default_when_using_String_and_DbCompiledModel_constructor

 public void ValidateOnSaveEnabled_is_on_by_default_when_using_String_and_DbCompiledModel_constructor()
 {
     using (var context = new F1Context(DefaultDbName<F1Context>(), CreateF1Model()))
     {
         Assert.True(context.Configuration.ValidateOnSaveEnabled);
     }
 }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:7,代码来源:DbContextTests.cs


示例11: TestDetectChangesWithSaveChanges

        private void TestDetectChangesWithSaveChanges(bool autoDetectChanges)
        {
            using (var context = new F1Context())
            {
                context.Database.Initialize(force: false);

                using (new TransactionScope())
                {
                    context.Configuration.AutoDetectChangesEnabled = autoDetectChanges;

                    var mclaren = context.Teams.Find(Team.McLaren);
                    var larryEntry = context.Entry(new Driver { Name = "Larry David" });
                    mclaren.Drivers.Add(larryEntry.Entity);

                    Assert.Equal(autoDetectChanges ? EntityState.Added : EntityState.Detached, larryEntry.State);

                    context.SaveChanges();

                    Assert.Equal(autoDetectChanges ? EntityState.Unchanged : EntityState.Detached, larryEntry.State);
                }
            }
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:22,代码来源:DbContextTests.cs


示例12: AutoDetectChangesEnabled_is_on_by_default_and_can_be_changed

        public void AutoDetectChangesEnabled_is_on_by_default_and_can_be_changed()
        {
            using (var context = new F1Context())
            {
                Assert.True(context.Configuration.AutoDetectChangesEnabled);

                context.Configuration.AutoDetectChangesEnabled = false;

                Assert.False(context.Configuration.AutoDetectChangesEnabled);
            }
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:11,代码来源:DbContextTests.cs


示例13: using

        public void Changing_proxy_creation_flag_after_ObjectContext_is_initialized_causes_proxy_creation_flag_in_DbContext_and_ObjectContext_to_change()
        {
            using (var context = new F1Context())
            {
                ValidateProxyCreation(context, proxyCreationEnabled: true);

                context.Configuration.ProxyCreationEnabled = false;
                ValidateProxyCreation(context, proxyCreationEnabled: false);

                context.Configuration.ProxyCreationEnabled = true;
                ValidateProxyCreation(context, proxyCreationEnabled: true);
            }
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:13,代码来源:DbContextTests.cs


示例14: Lazy_loading_can_be_switched_off_in_constructor_which_calls_to_base_ObjectContext_constructor

        public void Lazy_loading_can_be_switched_off_in_constructor_which_calls_to_base_ObjectContext_constructor()
        {
            var objectContext = GetObjectContext(new F1Context());
            objectContext.ContextOptions.LazyLoadingEnabled = true;

            using (
                var context = new F1Context(objectContext, dbContextOwnsObjectContext: true, lazyLoadingEnabled: false))
            {
                ValidateLazyLoading(context, false);
            }
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:11,代码来源:DbContextTests.cs


示例15: Proxy_creation_can_be_switched_off_in_constructor_which_calls_to_base_empty_constructor

 public void Proxy_creation_can_be_switched_off_in_constructor_which_calls_to_base_empty_constructor()
 {
     using (var context = new F1Context(proxyCreationEnabled: false))
     {
         ValidateProxyCreation(context, proxyCreationEnabled: false);
     }
 }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:7,代码来源:DbContextTests.cs


示例16: Proxy_creation_can_be_switched_off_in_constructor_which_calls_to_base_ObjectContext_constructor

        public void Proxy_creation_can_be_switched_off_in_constructor_which_calls_to_base_ObjectContext_constructor()
        {
            var objectContext = GetObjectContext(new F1Context());
            objectContext.ContextOptions.ProxyCreationEnabled = true;

            using (
                var context = new F1Context(objectContext, dbContextOwnsObjectContext: true, proxyCreationEnabled: false)
                )
            {
                ValidateProxyCreation(context, false);
            }
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:12,代码来源:DbContextTests.cs


示例17: ValidateProxyCreation

        private void ValidateProxyCreation(F1Context context, bool proxyCreationEnabled)
        {
            Assert.Equal(proxyCreationEnabled, context.Configuration.ProxyCreationEnabled);
            Assert.Equal(proxyCreationEnabled, GetObjectContext(context).ContextOptions.ProxyCreationEnabled);

            context.ChangeTracker.Entries().ToList().ForEach(e => e.State = EntityState.Detached);

            var driver = context.Drivers.First();
            if (proxyCreationEnabled)
            {
                Assert.NotEqual(typeof(Driver), driver.GetType());
            }
            else
            {
                Assert.Equal(typeof(Driver), driver.GetType());
            }
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:17,代码来源:DbContextTests.cs


示例18: TestDetectChanges

        private void TestDetectChanges(Action<F1Context> setupContext, Action<F1Context> actOnContext,
                                       bool autoDetectChanges, bool? expectDetectChanges = null)
        {
            using (var context = new F1Context())
            {
                context.Configuration.AutoDetectChangesEnabled = autoDetectChanges;

                setupContext(context);

                var mclaren = context.Teams.Find(Team.McLaren);
                var larryEntry = context.Entry(new Driver { Name = "Larry David" });
                mclaren.Drivers.Add(larryEntry.Entity);

                actOnContext(context);

                Assert.Equal(expectDetectChanges ?? autoDetectChanges ? EntityState.Added : EntityState.Detached,
                             larryEntry.State);
            }
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:19,代码来源:DbContextTests.cs


示例19: Proxy_creation_is_on_by_default_when_using_empty_constructor

 public void Proxy_creation_is_on_by_default_when_using_empty_constructor()
 {
     using (var context = new F1Context())
     {
         ValidateProxyCreation(context, proxyCreationEnabled: true);
     }
 }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:7,代码来源:DbContextTests.cs


示例20: ValidateOnSaveEnabled_is_on_by_default_when_using_empty_constructor

 public void ValidateOnSaveEnabled_is_on_by_default_when_using_empty_constructor()
 {
     using (var context = new F1Context())
     {
         Assert.True(context.Configuration.ValidateOnSaveEnabled);
     }
 }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:7,代码来源:DbContextTests.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Core.ConfuserContext类代码示例发布时间:2022-05-24
下一篇:
C# Api.Resource类代码示例发布时间: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