本文整理汇总了C#中NHibernate.Cfg.Configuration.SetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.SetProperty方法的具体用法?C# Configuration.SetProperty怎么用?C# Configuration.SetProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Cfg.Configuration
的用法示例。
在下文中一共展示了Configuration.SetProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AlterConfiguration
protected override void AlterConfiguration(Configuration config) {
config.SetProperty(NHibernate.Cfg.Environment.PrepareSql, Boolean.TrueString);
if (IsAzureSql()) {
config.SetProperty(NHibernate.Cfg.Environment.TransactionStrategy, typeof(ReliableAdoNetWithDistributedTransactionFactory).AssemblyQualifiedName);
}
}
示例2: SqlEntityBulkCopy
/// <summary>
/// Wrapper class to produce an Ado.Net Datatable from any entity,
/// and perform SqlBulkCopy operations
/// </summary>
public SqlEntityBulkCopy(string sqlCnnString, Type entityType)
{
if (Cfg == null)
{
//Note: The NHibernate.Cfg.Configuration is meant only as an initialization-time object.
//Note: NHibernate.ISessionFactory is immutable and does not retain any association back to the Session
Cfg = new Configuration();
//Cfg.SetProperty("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle");
Cfg.SetProperty("dialect", "NHibernate.Dialect.MsSql2008Dialect");
Cfg.SetProperty("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
Cfg.SetProperty("connection.driver_class", "NHibernate.Driver.SqlClientDriver");
Cfg.SetProperty("connection.connection_string", sqlCnnString);
//add all the mappings embedded in this assembly
Cfg.AddAssembly(typeof(SqlEntityBulkCopy).Assembly);
var sessionFactory = Cfg.BuildSessionFactory();
SessionFactoryImpl = (ISessionFactoryImplementor)sessionFactory;
}
EntityType = entityType;
//_session = SessionFactoryImpl.OpenSession();
_metaData = SessionFactoryImpl.GetClassMetadata(EntityType);
_persistentClass = Cfg.GetClassMapping(EntityType);
_sqlCnn = new SqlConnection(sqlCnnString);
_sqlBulkCopy = new SqlBulkCopy(_sqlCnn);
//Debug.WriteLine("EntityName = " + _metaData.EntityName);
//Debug.WriteLine("IdentifierPropertyName = " + _metaData.IdentifierPropertyName);
//Debug.WriteLine("IdentifierType = " + _metaData.IdentifierType);
BuildDataTable();
BuildAndMapSqlBulkCopy();
}
示例3: Main
static void Main()
{
Console.Title = "Samples.CustomNhMappings.XmlMapping";
var nhConfiguration = new Configuration();
nhConfiguration.SetProperty(Environment.ConnectionProvider, "NHibernate.Connection.DriverConnectionProvider");
nhConfiguration.SetProperty(Environment.ConnectionDriver, "NHibernate.Driver.Sql2008ClientDriver");
nhConfiguration.SetProperty(Environment.Dialect, "NHibernate.Dialect.MsSql2008Dialect");
nhConfiguration.SetProperty(Environment.ConnectionStringName, "NServiceBus/Persistence");
AddMappingsFromFilesystem(nhConfiguration);
var busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.CustomNhMappings.XmlMapping");
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.EnableInstallers();
var persistence = busConfiguration.UsePersistence<NHibernatePersistence>();
persistence.UseConfiguration(nhConfiguration);
using (var bus = Bus.Create(busConfiguration).Start())
{
var startOrder = new StartOrder
{
OrderId = "123"
};
bus.SendLocal(startOrder);
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}
示例4: ParseConnectionString
/// <summary>
/// Parses the connection string and creates the NHibernate configuration
/// </summary>
/// <param name="connect">NHibernate dialect, driver and connection string separated by ';'</param>
private void ParseConnectionString(string connect)
{
// Split out the dialect, driver, and connect string
char[] split = { ';' };
string[] parts = connect.Split(split, 3);
if (parts.Length != 3)
{
// TODO: make this a real exception type
throw new Exception("Malformed Inventory connection string '" + connect + "'");
}
dialect = parts[0];
// NHibernate setup
configuration = new Configuration();
configuration.SetProperty(Environment.ConnectionProvider,
"NHibernate.Connection.DriverConnectionProvider");
configuration.SetProperty(Environment.Dialect,
"NHibernate.Dialect." + dialect);
configuration.SetProperty(Environment.ConnectionDriver,
"NHibernate.Driver." + parts[1]);
configuration.SetProperty(Environment.ConnectionString, parts[2]);
//configuration.SetProperty(Environment.ShowSql, "true");
//configuration.SetProperty(Environment.GenerateStatistics, "false");
//configuration.AddAssembly("WebDAVSharp.NHibernateStorage");
configuration.AddAssembly("ModCableBeach");
}
示例5: SessionFactory
static SessionFactory()
{
var connectionString = @"Data Source=.\sqlexpress2014;Initial Catalog=BlogDatabase;Integrated Security=True";
var configuration = new Configuration();
configuration.DataBaseIntegration(
x =>
{
x.ConnectionString = connectionString;
x.Driver<SqlClientDriver>();
x.Dialect<MsSql2012Dialect>();
});
configuration.SetProperty(Environment.UseQueryCache, "true");
configuration.SetProperty(Environment.UseSecondLevelCache, "true");
configuration.SetProperty(Environment.CacheProvider, typeof(SysCacheProvider).AssemblyQualifiedName);
var mapper = new ModelMapper();
mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes());
mapper.BeforeMapBag += (modelInspector, member1, propertyCustomizer) =>
{
propertyCustomizer.Inverse(true);
propertyCustomizer.Cascade(Cascade.All | Cascade.DeleteOrphans);
};
mapper.BeforeMapManyToOne +=
(modelInspector, member1, propertyCustomizer) => { propertyCustomizer.NotNullable(true); };
mapper.BeforeMapProperty += (inspector, member, customizer) => customizer.NotNullable(true);
var mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();
configuration.AddMapping(mapping);
sessionFactory = configuration.BuildSessionFactory();
}
示例6: TestAccount
public static Boolean TestAccount(DatabaseAccountToken token, Boolean testMapping = false)
{
try
{
Configuration configuration = new Configuration();
configuration.SetProperty(NHibernate.Cfg.Environment.ConnectionString, token.ConnectionString);
configuration.SetProperty(NHibernate.Cfg.Environment.ConnectionDriver, String.Format("NHibernate.Driver.{0}", token.DatabaseDriver));
configuration.SetProperty(NHibernate.Cfg.Environment.Dialect, String.Format("NHibernate.Dialect.{0}", token.DatabaseDialect));
if (testMapping)
{
configuration.AddXml(token.Mapping);
using (ISessionFactory sessionFactory = configuration.BuildSessionFactory())
{
using (ISession session = sessionFactory.OpenSession())
{
return session.IsConnected;
}
}
}
else
{
using (ISessionFactory sessionFactory = configuration.BuildSessionFactory())
{
using (ISession session = sessionFactory.OpenSession())
{
return session.IsConnected;
}
}
}
}
catch (Exception ex)
{
return false;
}
}
示例7: Configure
protected override void Configure(Configuration configuration)
{
base.Configure(configuration);
configuration.SetProperty(Environment.UseQueryCache, "true");
configuration.SetProperty(Environment.CacheRegionPrefix, "criteriaquerytest");
configuration.SetProperty(Environment.UseSecondLevelCache, "true");
}
示例8: ConfigureConnection
private static void ConfigureConnection(Configuration configuration, string connectionString)
{
configuration.SetProperty(Environment.Dialect, "NHibernate.Dialect.MsSql2005Dialect");
configuration.SetProperty(Environment.ConnectionDriver, "NHibernate.Driver.SqlClientDriver");
configuration.SetProperty(Environment.ConnectionProvider, "NHibernate.Connection.DriverConnectionProvider");
configuration.SetProperty(Environment.ConnectionString, connectionString);
}
示例9: Configure
protected override void Configure(Configuration configuration)
{
configuration.SetProperty(Environment.UseSecondLevelCache, "false");
configuration.SetProperty(Environment.UseQueryCache, "false");
configuration.SetProperty(Environment.CacheProvider, null);
configuration.SetListener(ListenerType.PostCommitDelete, new PostCommitDelete());
}
示例10: Main
static void Main()
{
Configuration nhConfiguration = new Configuration();
nhConfiguration.SetProperty(Environment.ConnectionProvider, "NHibernate.Connection.DriverConnectionProvider");
nhConfiguration.SetProperty(Environment.ConnectionDriver, "NHibernate.Driver.Sql2008ClientDriver");
nhConfiguration.SetProperty(Environment.Dialect, "NHibernate.Dialect.MsSql2008Dialect");
nhConfiguration.SetProperty(Environment.ConnectionStringName, "NServiceBus/Persistence");
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.CustomNhMappings.Default");
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.EnableInstallers();
busConfiguration
.UsePersistence<NHibernatePersistence>()
.UseConfiguration(nhConfiguration);
using (IBus bus = Bus.Create(busConfiguration).Start())
{
bus.SendLocal(new StartOrder
{
OrderId = "123"
});
bus.SendLocal(new CompleteOrder
{
OrderId = "123"
});
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}
示例11: Configure
protected override void Configure(Configuration configuration)
{
base.Configure(configuration);
configuration.SetProperty("hibernate.search.default.directory_provider", typeof(FSDirectoryProvider).AssemblyQualifiedName);
configuration.SetProperty(Environment.AnalyzerClass, typeof(StopAnalyzer).AssemblyQualifiedName);
}
示例12: Configure
protected override void Configure(Configuration configuration)
{
base.Configure(configuration);
configuration.SetProperty("hibernate.search.default.directory_provider", typeof(Store.RAMDirectoryProvider).AssemblyQualifiedName);
configuration.SetProperty(Environment.AnalyzerClass, typeof(Lucene.Net.Analysis.StopAnalyzer).AssemblyQualifiedName);
configuration.SetProperty(Environment.WorkerScope, "transaction");
configuration.SetProperty(Environment.WorkerExecution, "sync"); // Note: It is WorkerPrefix in the Java version, but it must be a typo
}
示例13: Configure
protected override void Configure(Configuration cfg)
{
base.Configure(cfg);
cfg.SetProperty(Environment.ReleaseConnections, "after_transaction");
//cfg.SetProperty(Environment.ConnectionProvider, typeof(DummyConnectionProvider).AssemblyQualifiedName);
//cfg.SetProperty(Environment.GenerateStatistics, "true");
cfg.SetProperty(Environment.BatchSize, "0");
}
示例14: CacheDisabled
public void CacheDisabled()
{
Configuration cfg = new Configuration();
cfg.SetProperty(Environment.UseSecondLevelCache, "false");
cfg.SetProperty(Environment.UseQueryCache, "false");
cfg.SetProperty(Environment.CacheProvider, null);
cfg.BuildSessionFactory().Close();
}
示例15: configurarSesiones
public static void configurarSesiones()
{
cfg = new Configuration();
cfg.SetProperty("dialect", "NHibernate.Dialect.MySQLDialect");
cfg.SetProperty("connection.driver_class", "NHibernate.Driver.MySqlDataDriver");
cfg.SetProperty("connection.connection_string", "Server='" + servidor + "';Database='" + baseDatos + "';User ID=" + usuario + ";Password=" + pass + ";CharSet=utf8");
cfg.AddAssembly("SIMO_CORE");
sesiones = cfg.BuildSessionFactory();
}