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


C# DbCompiledModel类代码示例

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


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

示例1: CreateModel_uses_DbCompiledModel_from_ModelStore_when_available

        public void CreateModel_uses_DbCompiledModel_from_ModelStore_when_available()
        {
            var store = new Mock<DbModelStore>();

            var dbCompiledModelInStore = new DbCompiledModel();
            store.Setup(c => c.TryLoad(It.IsAny<Type>())).Returns(dbCompiledModelInStore);
            store.Setup(c => c.Save(It.IsAny<Type>(), It.IsAny<DbModel>()));

            try
            {
                var dependencyResolver = new SingletonDependencyResolver<DbModelStore>(store.Object);
                MutableResolver.AddResolver<DbModelStore>(dependencyResolver);

                var mockContext = new Mock<LazyInternalContext>(
                    new Mock<DbContext>().Object, new Mock<IInternalConnection>().Object, null, null, null, null, null)
                {
                    CallBase = true
                };

                var model = LazyInternalContext.CreateModel(mockContext.Object);
             
                Assert.Same(dbCompiledModelInStore, model);

                store.Verify(c => c.TryLoad(It.IsAny<Type>()), Times.Once(),
                    "should load existing model");

                store.Verify(c => c.Save(It.IsAny<Type>(), It.IsAny<DbModel>()), Times.Never(),
                    "should not call Save when loading model from store");
            }
            finally //clean up
            {
                MutableResolver.ClearResolvers();
            }
        }
开发者ID:aspnet,项目名称:EntityFramework6,代码行数:34,代码来源:LazyInternalContextTests.cs

示例2: CreateModel_does_not_use_ModelStore_for_HistoryContext

        public void CreateModel_does_not_use_ModelStore_for_HistoryContext()
        {
            var store = new Mock<DbModelStore>();

            var dbCompiledModelInStore = new DbCompiledModel();
            store.Setup(c => c.TryLoad(It.IsAny<Type>())).Returns(dbCompiledModelInStore);
            store.Setup(c => c.Save(It.IsAny<Type>(), It.IsAny<DbModel>()));

            try
            {
                var dependencyResolver = new SingletonDependencyResolver<DbModelStore>(store.Object);
                MutableResolver.AddResolver<DbModelStore>(dependencyResolver);

                var mockContext = new Mock<LazyInternalContext>(
                    new MockHistoryContext(), new Mock<IInternalConnection>().Object, null, null, null, null, null)
                {
                    CallBase = true
                };
                mockContext.Object.ModelProviderInfo = ProviderRegistry.Sql2008_ProviderInfo;

                var model = LazyInternalContext.CreateModel(mockContext.Object);

                Assert.NotSame(dbCompiledModelInStore, model);

                store.Verify(c => c.TryLoad(It.IsAny<Type>()), Times.Never(),
                    "should not call store for HistoryContext");

                store.Verify(c => c.Save(It.IsAny<Type>(), It.IsAny<DbModel>()), Times.Never(),
                    "should not call store for HistoryContext");
            }
            finally //clean up
            {
                MutableResolver.ClearResolvers();
            }
        }
开发者ID:aspnet,项目名称:EntityFramework6,代码行数:35,代码来源:LazyInternalContextTests.cs

示例3: OwDbContext

 /// <summary>
 /// Constructor.
 /// 构造函数
 /// </summary>
 protected OwDbContext(DbCompiledModel model)
     : base(model)
 {
     Logger = NullLogger.Instance;
     OwSession = NullOwSession.Instance;
     EntityChangeEventHelper = NullEntityChangeEventHelper.Instance;
 }
开发者ID:zhongkai1010,项目名称:OneWork,代码行数:11,代码来源:OwDbContext.cs

示例4: AbpDbContext

 /// <summary>
 /// Constructor.
 /// </summary>
 protected AbpDbContext(DbCompiledModel model)
     : base(model)
 {
     Logger = NullLogger.Instance;
     AbpSession = NullAbpSession.Instance;
     EntityChangedEventHelper = NullEntityChangedEventHelper.Instance;
 }
开发者ID:mlkj,项目名称:2016YL.MaterialSystem,代码行数:10,代码来源:AbpDbContext.cs

示例5: AddDbCompiledModelAnnotation

        public static IEdmModel AddDbCompiledModelAnnotation(this IEdmModel model, DbCompiledModel dbCompiledModel)
        {
            var annotation = new DbCompiledModelAnnotation(dbCompiledModel);
            model.SetAnnotationValue(model, annotation);

            return model;
        }
开发者ID:denisivan0v,项目名称:nuclear-river,代码行数:7,代码来源:EdmModelExtensions.cs

示例6: Calculate

        /// <summary>
        ///     Calculates an SHA256 hash of the EDMX from the given code first model. This is the hash stored in
        ///     the database in the EdmMetadata table in EF 4.1/4.2. The hash is always calculated using a v2 schema
        ///     as was generated by EF 4.1/4.2 and with the <see cref = "EdmMetadata" /> entity included in the model.
        /// </summary>
        public virtual string Calculate(DbCompiledModel compiledModel)
        {
            //Contract.Requires(compiledModel != null);
            //Contract.Requires(compiledModel.ProviderInfo != null);
            //Contract.Requires(compiledModel.CachedModelBuilder != null);

            var providerInfo = compiledModel.ProviderInfo;
            var modelBuilder = compiledModel.CachedModelBuilder.Clone();

            // Add back in the EdmMetadata class because the hash created by EF 4.1 and 4.2 will contain it.
            EdmMetadataContext.ConfigureEdmMetadata(modelBuilder.ModelConfiguration);

            var databaseMetadata = modelBuilder.Build(providerInfo).DatabaseMapping.Database;
            databaseMetadata.Version = 2.0; // Ensures SSDL version matches that created by EF 4.1/4.2

            var stringBuilder = new StringBuilder();
            using (var xmlWriter = XmlWriter.Create(
                stringBuilder, new XmlWriterSettings
                    {
                        Indent = true
                    }))
            {
                new SsdlSerializer().Serialize(
                    databaseMetadata,
                    providerInfo.ProviderInvariantName,
                    providerInfo.ProviderManifestToken,
                    xmlWriter);
            }

            return ComputeSha256Hash(stringBuilder.ToString());
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:36,代码来源:ModelHashCalculator.cs

示例7: ChebayDBContext

 private ChebayDBContext(DbCompiledModel model, string name)
     : base(con, model)
 {
     tenant_name = name;
     Database.SetInitializer<ChebayDBContext>(null);
     this.Configuration.LazyLoadingEnabled = false;
 }
开发者ID:AleAnonMallo,项目名称:Chebay-1,代码行数:7,代码来源:ChebayDBContext.cs

示例8: QdfDbContext

 /// <summary>
 /// Constructor.
 /// </summary>
 protected QdfDbContext(string nameOrConnectionString, DbCompiledModel model)
     : base(nameOrConnectionString, model)
 {
     //Logger = NullLogger.Instance;
     QdfSession = NullQdfSession.Instance;
     EntityChangedEventHelper = NullEntityChangedEventHelper.Instance;
 }
开发者ID:lizhi5753186,项目名称:QDF,代码行数:10,代码来源:QdfDbContext.cs

示例9: F1Context

 public F1Context(
     DbConnection existingConnection, DbCompiledModel model, bool contextOwnsConnection, bool lazyLoadingEnabled = true,
     bool proxyCreationEnabled = true)
     : base(existingConnection, model, contextOwnsConnection)
 {
     SetContextOptions(lazyLoadingEnabled, proxyCreationEnabled);
 }
开发者ID:christiandpena,项目名称:entityframework,代码行数:7,代码来源:F1Context.cs

示例10: DbContextBase

 public DbContextBase(
     string nameOrConnectionString,
     DbCompiledModel model,
     IExceptionMapper exceptionMapper = null)
     : base(nameOrConnectionString, model)
 {
     SetExceptionMapper(exceptionMapper);
 }
开发者ID:jcorrea-origin,项目名称:Bardock.Utils,代码行数:8,代码来源:DbContextBase.cs

示例11: Model

        public static DbCompiledModel Model(SqlConnection con)
        {
            if ((_builder == null) || (_model == null))
            {
                _builder = new DbModelBuilder();
                _builder.Configurations.Add(new ProductConfiguration());

                var edm = _builder.Build(con);
                _model = edm.Compile();
            }
            return _model;
        }
开发者ID:fahrigoktuna,项目名称:FKArchitecture,代码行数:12,代码来源:EFModelBuilder.cs

示例12: DbContextBase

 public DbContextBase(
     string nameOrConnectionString,
     DbCompiledModel model,
     IExceptionMapper exceptionMapper = null,
     IEntityAdder entityAdder = null,
     IEntityUpdater entityUpdater = null,
     IEntityDeleter entityDeleter = null,
     IEntityDetacher entityDetacher = null)
     : base(nameOrConnectionString, model)
 {
     Init(exceptionMapper, entityAdder, entityUpdater, entityDeleter, entityDetacher);
 }
开发者ID:fflores-origin,项目名称:Bardock.Utils,代码行数:12,代码来源:DbContextBase.cs

示例13: LazyInternalContext

        /// <summary>
        ///     Constructs a <see cref = "LazyInternalContext" /> for the given <see cref = "DbContext" /> owner that will be initialized
        ///     on first use.
        /// </summary>
        /// <param name = "owner">The owner <see cref = "DbContext" />.</param>
        /// <param name = "internalConnection">Responsible for creating a connection lazily when the context is used for the first time.</param>
        /// <param name = "model">The model, or null if it will be created by convention</param>
        public LazyInternalContext(
            DbContext owner,
            IInternalConnection internalConnection,
            DbCompiledModel model,
            IDbModelCacheKeyFactory cacheKeyFactory = null)
            : base(owner)
        {
            //Contract.Requires(internalConnection != null);

            _internalConnection = internalConnection;
            _model = model;
            _cacheKeyFactory = cacheKeyFactory ?? new DefaultModelCacheKeyFactory();

            _createdWithExistingModel = model != null;
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:22,代码来源:LazyInternalContext.cs

示例14: AbpDbContext

 /// <summary>
 /// Constructor.
 /// </summary>
 protected AbpDbContext(string nameOrConnectionString, DbCompiledModel model)
     : base(nameOrConnectionString, model)
 {
     InitializeDbContext();
 }
开发者ID:Zbun,项目名称:Gld.Activity.Project,代码行数:8,代码来源:AbpDbContext.cs

示例15: SpSynthDbContext

 public SpSynthDbContext(DbConnection existingConnection, DbCompiledModel model, bool contextOwnsConnection)
     : base(existingConnection, model, contextOwnsConnection)
 {
 }
开发者ID:CBSAdvisor,项目名称:SpSynthesis,代码行数:4,代码来源:SpSynthDbContext.cs


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