本文整理汇总了C#中NHibernate.Mapping.ByCode.ConventionModelMapper.CompileMappingForAllExplicitlyAddedEntities方法的典型用法代码示例。如果您正苦于以下问题:C# ConventionModelMapper.CompileMappingForAllExplicitlyAddedEntities方法的具体用法?C# ConventionModelMapper.CompileMappingForAllExplicitlyAddedEntities怎么用?C# ConventionModelMapper.CompileMappingForAllExplicitlyAddedEntities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Mapping.ByCode.ConventionModelMapper
的用法示例。
在下文中一共展示了ConventionModelMapper.CompileMappingForAllExplicitlyAddedEntities方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestFixtureSetUp
public void TestFixtureSetUp()
{
configuration = new Configuration();
configuration.SessionFactory()
.Integrate.Using<SQLiteDialect>()
.Connected.Using("Data source=testdb")
.AutoQuoteKeywords()
.LogSqlInConsole()
.EnableLogFormattedSql();
var mapper = new ConventionModelMapper();
mapper.Class<Foo>(cm => { });
mapper.Class<Bar>(cm => { });
CustomizeMapping(mapper);
var mappingDocument = mapper.CompileMappingForAllExplicitlyAddedEntities();
new XmlSerializer(typeof(HbmMapping)).Serialize(Console.Out, mappingDocument);
configuration.AddDeserializedMapping(mappingDocument, "Mappings");
new SchemaExport(configuration).Create(true, true);
sessionFactory = configuration.BuildSessionFactory();
using (var session = sessionFactory.OpenSession())
using (var tx = session.BeginTransaction())
{
var foo = new Foo { Bars = CreateCollection() };
foo.Bars.Add(new Bar { Data = 1 });
foo.Bars.Add(new Bar { Data = 2 });
id = session.Save(foo);
tx.Commit();
}
sessionFactory.Statistics.IsStatisticsEnabled = true;
}
示例2: Main
static void Main(string[] args)
{
SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
var mapper = new ConventionModelMapper();
mapper.Class<SomeAreaClass>(c =>
{
c.Property(x => x.Area, m =>
{
m.Type<MsSql2008GeographyType>();
m.NotNullable(true);
});
});
var cfg = new Configuration()
.DataBaseIntegration(db =>
{
db.ConnectionString = "YourConnectionString";
db.Dialect<MsSql2012GeographyDialect>();
});
cfg
.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());
cfg
.AddAuxiliaryDatabaseObject(new SpatialAuxiliaryDatabaseObject(cfg));
new SchemaExport(cfg).Execute(false, true, false);
}
示例3: GetSessionFactory
public static ISessionFactory GetSessionFactory()
{
var config = new Configuration();
config.SessionFactory().Integrate.Using<SQLiteDialect>().Connected.Using("Data source=nhtest.sqlite").AutoQuoteKeywords();
var mapper = new ConventionModelMapper();
Map(mapper);
config.AddDeserializedMapping(mapper.CompileMappingForAllExplicitlyAddedEntities(), "Mappings");
SchemaMetadataUpdater.QuoteTableAndColumns(config);
new SchemaUpdate(config).Execute(false, true);
return config.BuildSessionFactory();
}
示例4: GetSessionFactory
public static ISessionFactory GetSessionFactory()
{
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
var config = new Configuration();
//config.SessionFactory().Integrate.Using<SQLiteDialect>().Connected.Using("Data source=nhtest.sqlite").AutoQuoteKeywords();
config.SessionFactory().Integrate.Using<SQLiteDialect>().Connected.Using(String.Format("Data source={0}", Path.Combine(clientPath, "nhtest.sqlite"))).AutoQuoteKeywords();
var mapper = new ConventionModelMapper();
Map(mapper);
config.AddDeserializedMapping(mapper.CompileMappingForAllExplicitlyAddedEntities(), "Mappings");
SchemaMetadataUpdater.QuoteTableAndColumns(config);
new SchemaUpdate(config).Execute(false, true);
return config.BuildSessionFactory();
}
示例5: GetMappingWithParentInCompo
private HbmMapping GetMappingWithParentInCompo()
{
var mapper = new ConventionModelMapper();
mapper.Class<MyClass>(x =>
{
x.Id(c => c.Id);
x.Component(c => c.Compo);
});
mapper.Component<MyCompo>(x =>
{
x.Property(c => c.Something);
});
return mapper.CompileMappingForAllExplicitlyAddedEntities();
}
示例6: TestFixtureSetUp
public void TestFixtureSetUp()
{
var configuration = new Configuration();
configuration.SessionFactory()
.Integrate.Using<SQLiteDialect>()
.Connected.Using("Data source=testdb")
.AutoQuoteKeywords()
.LogSqlInConsole()
.EnableLogFormattedSql();
var mapper = new ConventionModelMapper();
MapClasses(mapper);
var mappingDocument = mapper.CompileMappingForAllExplicitlyAddedEntities();
new XmlSerializer(typeof(HbmMapping)).Serialize(Console.Out, mappingDocument);
configuration.AddDeserializedMapping(mappingDocument, "Mappings");
new SchemaExport(configuration).Create(true, true);
sessionFactory = configuration.BuildSessionFactory();
}
示例7: InitSessionFactory
private static void InitSessionFactory(ServiceContext context)
{
var cfg = new Configuration();
var mapper = new ConventionModelMapper();
mapper.BeforeMapClass +=
(inspector, type, map) =>
{
var idProperty = type.GetProperty("Id");
map.Id(idProperty, idMapper => { });
};
mapper.BeforeMapProperty +=
(inspector, propertyPath, map) => map.Column(propertyPath.ToColumnName());
mapper.BeforeMapManyToOne +=
(inspector, propertyPath, map) => map.Column(propertyPath.ToColumnName() + "Id");
foreach (var plugin in context.GetAllPlugins())
{
plugin.InitDbModel(mapper);
cfg.AddAssembly(plugin.GetType().Assembly);
}
var mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();
cfg.DataBaseIntegration(dbConfig =>
{
dbConfig.Dialect<MsSqlCe40Dialect>();
dbConfig.Driver<SqlServerCeDriver>();
dbConfig.ConnectionStringName = "common";
});
cfg.AddDeserializedMapping(mapping, null); //Loads nhibernate mappings
var sessionFactory = cfg.BuildSessionFactory();
context.InitSessionFactory(sessionFactory);
}
示例8: BuildConfiguration
public Configuration BuildConfiguration()
{
var mapper = new ConventionModelMapper();
CollectMappingContributorsAndApply(mapper);
AR.RaiseOnMapperCreated(mapper, this);
var mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();
mapping.autoimport = Source.AutoImport;
mapping.defaultlazy = Source.Lazy;
if (Source.Debug) {
try {
File.WriteAllText(
Path.Combine(
AppDomain.CurrentDomain.BaseDirectory,
Name + "mapping.hbm.xml"
), mapping.AsString()
);
} catch { /* just bail out */ }
}
AR.RaiseOnHbmMappingCreated(mapping, this);
var cfg = new Configuration();
if (Source.NamingStrategyImplementation != null)
cfg.SetNamingStrategy((INamingStrategy) Activator.CreateInstance(Source.NamingStrategyImplementation));
foreach(var key in Properties.AllKeys)
{
cfg.Properties[key] = Properties[key];
}
CollectAllContributorsAndRegister(cfg);
cfg.AddMapping(mapping);
AR.RaiseOnConfigurationCreated(cfg, this);
return cfg;
}
示例9: BuildSessionFactory
static Configuration BuildSessionFactory() {
var config = new Configuration();
config.SetProperties(CreateSessionFactoryDefaultProperties());
config.SetProperty(NhCfgEnv.ConnectionString, "Data Source=db-dev4.gdepb.gov.cn;Initial Catalog=Test;Persist Security Info=True;User ID=udev;Password=devdev");
var mapper = new ConventionModelMapper();
mapper.AddMapping(new UserMapping());
mapper.AddMapping(new RoleMapping());
var mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();
config.AddMapping(mapping);
return config;
}