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


C# ModelBuilder.Build方法代码示例

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


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

示例1: GivenModel_WhenDeriving_ThenRequiredRelationsMustExist

        public void GivenModel_WhenDeriving_ThenRequiredRelationsMustExist()
        {
            var builder = new ModelBuilder(this.DatabaseSession);
            builder.Build();

            Assert.IsTrue(this.DatabaseSession.Derive().HasErrors);

            this.DatabaseSession.Rollback();

            builder.WithName("name").Build();

            Assert.IsFalse(this.DatabaseSession.Derive().HasErrors);
        }
开发者ID:Allors,项目名称:apps,代码行数:13,代码来源:ProductFeatureTests.cs

示例2: Model

 public static DbModel Model(SqlConnection con)
 {
     if ((_builder == null) || (_model == null))
     {
         _builder = new ModelBuilder();
         _builder.Configurations.Add(new AuthorConfiguration());
         _builder.Configurations.Add(new TitlesConfiguration());
         _builder.Configurations.Add(new PublisherConfiguration());
         var edm=_builder.Build(con);
         _model = new DbModel(edm);
     }
     return _model; ;
 }
开发者ID:sonyarouje,项目名称:PublicShare,代码行数:13,代码来源:EFModelBuilder.cs

示例3: RunDirectoryScan

        string RunDirectoryScan(string directory)
        {
            ModelBuilder builder = new ModelBuilder();
            DirStatModel model = builder.Build(new NDirInfo(directory));
            NDirStat.TreeModel treeModel = new NDirStat.TreeModel(model);

            string json = BuildJSON(treeModel.GetRoot());
            json = string.Format(@"{{ \""data\"": {0}}}", json);

            // call into script to 
            string func = "updateTree(\"" + json + "\")";
            return func;
        }
开发者ID:joncham,项目名称:NDirStat,代码行数:13,代码来源:MainWindow.cs

示例4: script_Edmx

        public void script_Edmx()
        {
            Console.WriteLine(MethodBase.GetCurrentMethod().Name);

            var mb = new ModelBuilder();
            mb.Conventions.Remove<IncludeMetadataConvention>();
            mb.Configurations.Add(new NrConfiguration());
            // TODO: actually since CTP5 this is optional;
            mb.Entity<Guess>().HasRequired(g => g.Board);
            mb.Entity<Win>().HasRequired(g => g.Draw);
            mb.Entity<Board>().Property(x => x.AsArray);
            mb.Entity<Board>().Property(x => x.AsString);

            var providerInfo = new DbProviderInfo("System.Data.SqlServerCe.4.0", "2008");
            var edm = mb.Build(providerInfo);
            XmlWriter writer = new XmlTextWriter("DomainModel.edmx", Encoding.UTF8);
            edm.WriteEdmx(providerInfo, writer);
            writer.Close();
            Console.WriteLine("\tsee test/bin for .edmx/");
        }
开发者ID:bjornebjornson,项目名称:LottoEf4,代码行数:20,代码来源:Infrastructure.cs

示例5: CreateDbModel

        private static DbModel CreateDbModel(DbConnection connection)
        {
            var modelBuilder = new ModelBuilder();

            IEnumerable<Type> configurationTypes = typeof(DatabaseFactory).Assembly
                .GetTypes()
                .Where(
                    type =>
                    type.IsPublic && type.IsClass && !type.IsAbstract && !type.IsGenericType && type.BaseType != null &&
                    type.BaseType.IsGenericType &&
                    (type.BaseType.GetGenericTypeDefinition() == typeof(EntityTypeConfiguration<>) ||
                     type.BaseType.GetGenericTypeDefinition() == typeof(ComplexTypeConfiguration<>)) && (type.GetConstructor(Type.EmptyTypes) != null));

            foreach (var configuration in configurationTypes.Select(Activator.CreateInstance))
            {
                modelBuilder.Configurations.Add((dynamic)configuration);
            }

            DbDatabaseMapping mapping = modelBuilder.Build(connection);

            return new DbModel(mapping);
        }
开发者ID:hester000,项目名称:bolf-tracker-mvc,代码行数:22,代码来源:DatabaseFactory.cs


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