本文整理汇总了C#中AutoPersistenceModel.BuildMappings方法的典型用法代码示例。如果您正苦于以下问题:C# AutoPersistenceModel.BuildMappings方法的具体用法?C# AutoPersistenceModel.BuildMappings怎么用?C# AutoPersistenceModel.BuildMappings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoPersistenceModel
的用法示例。
在下文中一共展示了AutoPersistenceModel.BuildMappings方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyMapping
private void VerifyMapping(AutoPersistenceModel model, Action<CompositeIdMapping> verifier)
{
var idMapping = model.BuildMappings()
.First()
.Classes
.First()
.Id
;
idMapping.ShouldBeOfType(typeof(CompositeIdMapping));
verifier((CompositeIdMapping)idMapping);
}
示例2: BuildPersistenceModel
public AutoPersistenceModel BuildPersistenceModel()
{
var persistenceModel = new AutoPersistenceModel();
persistenceModel.Conventions.Setup(c =>
{
c.Add(typeof (ForeignKeyNameConvention));
c.Add(typeof (ReferenceConvention));
c.Add(typeof (PrimaryKeyNameConvention));
c.Add(typeof (TableNameConvention));
});
persistenceModel.AddMappingsFromAssembly(AssemblyMapper);
persistenceModel.BuildMappings();
persistenceModel.WriteMappingsTo(@"./");
return persistenceModel;
}
示例3: GetHBMFilesForFluentFromCSProj
public static IEnumerable<string> GetHBMFilesForFluentFromCSProj(CSProjFile csproj, string outputPath)
{
string assemblyName = csproj.GetAssemblyName();
IEnumerable<string> outputPaths = csproj.GetOutputPaths();
DateTime latestAssemblyDate = new DateTime(1900, 1, 1);
string latestAssembly = "";
foreach (string folder in outputPaths)
{
string assemblyPath = Path.Combine(folder, assemblyName);
if (File.Exists(assemblyPath))
{
DateTime lastWriteTime = File.GetLastWriteTimeUtc(assemblyPath);
if (lastWriteTime > latestAssemblyDate)
{
latestAssemblyDate = lastWriteTime;
latestAssembly = assemblyPath;
}
}
}
if (string.IsNullOrEmpty(latestAssembly))
throw new FluentNHibernateCompiledAssemblyMissingException("No compiled assembly found. A compiled assembly is required for Fluent NHibernate. Please recompile your project.");
System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom(latestAssembly);
FluentCompileLatestAssemblyDir = Path.GetDirectoryName(latestAssembly);
try
{
assembly.ModuleResolve += new System.Reflection.ModuleResolveEventHandler(assembly_ModuleResolve);
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += new ResolveEventHandler(CurrentDomain_ReflectionOnlyAssemblyResolve);
if (!Directory.Exists(outputPath))
Directory.CreateDirectory(outputPath);
//var sessionFactory = FluentNHibernate.Cfg.Fluently.Configure()
// .Database(FluentNHibernate.Cfg.Db.MsSqlConfiguration.MsSql2008
// .ConnectionString("Data Source=STN_DEV;Initial Catalog=FNHProviderDB;Integrated Security=SSPI;")
// )
// .Mappings(m => m.FluentMappings.AddFromAssembly(assembly).ExportTo(outputPath))
// .BuildConfiguration();
AutoPersistenceModel mappings = new AutoPersistenceModel();
mappings.AddMappingsFromAssembly(assembly);
mappings.BuildMappings();
mappings.WriteMappingsTo(outputPath);
return Directory.GetFiles(outputPath).ToList();
}
finally
{
assembly.ModuleResolve -= assembly_ModuleResolve;
AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve -= CurrentDomain_ReflectionOnlyAssemblyResolve;
}
}