本文整理汇总了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);
}
示例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; ;
}
示例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;
}
示例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/");
}
示例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);
}