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


C# AutoPersistenceModel.BuildMappings方法代码示例

本文整理汇总了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);
		}
开发者ID:jjchoi,项目名称:fluent-nhibernate,代码行数:12,代码来源:CompositeIdOverrides.cs

示例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;
    }
开发者ID:Joebeazelman,项目名称:rebelcmsxu5,代码行数:20,代码来源:NHibernateComponentModule.cs

示例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;
            }
        }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:58,代码来源:ProjectLoader.cs


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