本文整理汇总了C#中NHibernate.Cfg.Configuration.Proxy方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.Proxy方法的具体用法?C# Configuration.Proxy怎么用?C# Configuration.Proxy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Cfg.Configuration
的用法示例。
在下文中一共展示了Configuration.Proxy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenSession
public static ISession OpenSession()
{
if (sessionFactory == null)
{
System.Collections.Specialized.NameValueCollection sets = System.Configuration.ConfigurationManager.AppSettings;
//获取连接字符串
string server = Utilities.GetConfigValue("server");
string pwd = VTMS.Common.Utilities.Base64Dencrypt(Utilities.GetConfigValue("DBPassword"));
string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
connectionString = string.Format(connectionString, server, pwd);
try
{
Configuration cfg = new Configuration().Configure();
cfg.Proxy(p => p.ProxyFactoryFactory<NHibernate.Bytecode.DefaultProxyFactoryFactory>());
cfg.DataBaseIntegration(db =>
{
db.ConnectionString = connectionString;
});
sessionFactory = cfg.BuildSessionFactory();
}
catch (Exception e)
{
VTMS.Common.MessageUtil.ShowError("无法登陆服务器,请检查服务器IP设置是否正确,错误信息为:" + e.Message);
}
}
return sessionFactory.OpenSession();
}
示例2: BuildConfiguration
public Configuration BuildConfiguration(string connectionString, string sessionFactoryName)
{
Contract.Requires(!string.IsNullOrEmpty(connectionString), "ConnectionString is null or empty");
Contract.Requires(!string.IsNullOrEmpty(sessionFactoryName), "SessionFactory name is null or empty");
Contract.Requires(!string.IsNullOrEmpty(_databaseSchema), "Database Schema is null or empty");
Contract.Requires(_configurator != null, "Configurator is null");
return CatchExceptionHelper.TryCatchFunction(
() =>
{
DomainTypes = GetTypeOfEntities(_assemblies);
if (DomainTypes == null)
throw new Exception("Type of domains is null");
var configure = new Configuration();
configure.SessionFactoryName(sessionFactoryName);
configure.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>());
configure.DataBaseIntegration(db => GetDatabaseIntegration(db, connectionString));
if (_configurator.GetAppSettingString("IsCreateNewDatabase").ConvertToBoolean())
{
configure.SetProperty("hbm2ddl.auto", "create-drop");
}
configure.Properties.Add("default_schema", _databaseSchema);
configure.AddDeserializedMapping(GetMapping(),
_configurator.GetAppSettingString("DocumentFileName"));
SchemaMetadataUpdater.QuoteTableAndColumns(configure);
return configure;
}, Logger);
}
示例3: PrepareSessionFactory
public void PrepareSessionFactory()
{
Configuration = new Configuration();
Configuration.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>())
.DataBaseIntegration(db =>
{
db.ConnectionStringName = "db";
db.Dialect<MsSql2008Dialect>();
});
Configuration.SetProperty("show_sql", "true");
Configuration.SetDefaultAssembly("NHibernateDeepDive");
Configuration.SetDefaultNamespace("NHibernate_Deep_Dive.Entities");
Configuration.AddXmlFile("ClearDatabaseScript.hbm.xml");
foreach (var mappingFile in Directory.GetFiles(MappingsDirectory))
{
Configuration.AddXmlFile(mappingFile);
}
AdjustConfiguration(Configuration);
Configuration.SessionFactory().GenerateStatistics();
SessionFactory = Configuration.BuildSessionFactory();
//new SchemaExport(Configuration).Drop(false, true);
new SchemaExport(Configuration).Execute(false, true, false);
BeforeTestRun();
PopulateDatabase();
HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize();
}
示例4: Initialize
public static Configuration Initialize()
{
INHibernateConfigurationCache cache = new NHibernateConfigurationFileCache();
var mappingAssemblies = new[] {
typeof(ActionConfirmation<>).Assembly.GetName().Name
};
var configuration = cache.LoadConfiguration(CONFIG_CACHE_KEY, null, mappingAssemblies);
if (configuration == null) {
configuration = new Configuration();
configuration
.Proxy(p => p.ProxyFactoryFactory<DefaultProxyFactoryFactory>())
.DataBaseIntegration(db => {
db.ConnectionStringName = "DonSharpLiteConnectionString";
db.Dialect<MsSql2008Dialect>();
})
.AddAssembly(typeof(ActionConfirmation<>).Assembly)
.CurrentSessionContext<LazySessionContext>();
var mapper = new ConventionModelMapper();
mapper.WithConventions(configuration);
cache.SaveConfiguration(CONFIG_CACHE_KEY, configuration);
}
return configuration;
}
示例5: Main
private static void Main()
{
NHibernateProfiler.Initialize();
var cfg = new Configuration();
cfg.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>())
.DataBaseIntegration(db => {
db.ConnectionStringName = "scratch";
db.Dialect<MsSql2008Dialect>();
db.BatchSize = 500;
})
.AddAssembly(Assembly.GetExecutingAssembly())
.SessionFactory().GenerateStatistics();
new SchemaExport(cfg).Execute(script: false, export: true, justDrop: false);
var sessionFactory = cfg.BuildSessionFactory();
using(var session = sessionFactory.OpenSession())
using(var tx = session.BeginTransaction()) {
// NHibernate code goes here
tx.Commit();
}
Console.WriteLine("Press <ENTER> to exit...");
Console.ReadLine();
}
示例6: BasicConfiguration
public BasicConfiguration(IConnectionString connectionString) {
_configuration = new Configuration();
_configuration.Proxy(p => p.ProxyFactoryFactory<DefaultProxyFactoryFactory>())
.DataBaseIntegration(db => {
db.ConnectionString = connectionString.FormattedConnectionString;
db.Dialect<MsSql2008Dialect>();
})
.AddAssembly(typeof(NHTestEntity).Assembly);
}
示例7: Apply
public virtual void Apply(Configuration configuration, IDatabaseProvider databaseProvider)
{
configuration.CurrentSessionContext<CallSessionContext>();
configuration.DataBaseIntegration(db => SetDatabase(db, databaseProvider, configuration));
configuration.Cache(SetCache);
configuration.Proxy(SetProxy);
}
示例8: ConfigureNHibernate
public static Configuration ConfigureNHibernate()
{
var configure = new Configuration();
configure.SessionFactoryName("Demo");
configure.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>());
configure.DataBaseIntegration(db =>
{
db.Dialect<MsSql2008Dialect>();
db.Driver<SqlClientDriver>();
db.ConnectionString = ConnectionString;
db.LogSqlInConsole = true;//用于显示输出SQL
});
return configure;
}
示例9: CreateConfiguration
public static Configuration CreateConfiguration()
{
var configuration = new Configuration();
configuration
.Proxy(p => p.ProxyFactoryFactory<DefaultProxyFactoryFactory>())
.DataBaseIntegration(db => {
db.ConnectionStringName = "DefaultConnection";
db.Dialect<MsSql2008Dialect>();
})
.AddAssembly(typeof(Entity).Assembly)
.CurrentSessionContext<LazySessionContext>();
return configuration;
}
示例10: Initialize
public static Configuration Initialize() {
Configuration configuration = new Configuration();
configuration
.Proxy(p => p.ProxyFactoryFactory<DefaultProxyFactoryFactory>())
.DataBaseIntegration(db => {
db.ConnectionStringName = "CaTSConnectionString";
db.Dialect<MsSql2008Dialect>();
})
.AddAssembly(typeof(ActionConfirmation<>).Assembly)
.CurrentSessionContext<LazySessionContext>();
ConventionModelMapper mapper = new ConventionModelMapper();
mapper.WithConventions(configuration);
return configuration;
}
示例11: Init
private static NHibernate.ISessionFactory Init()
{
var config = new Configuration();
config.Proxy(proxy => proxy.ProxyFactoryFactory<DefaultProxyFactoryFactory>());
config.DataBaseIntegration(db =>
{
db.Dialect<SQLiteDialect>();
db.ConnectionString = @"Data Source=|DataDirectory|\Test.db";
//db.Driver<SQLite20Driver>();
db.SchemaAction = SchemaAutoAction.Create;
db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
});
config.AddDeserializedMapping(InternalHelper.GetAllMapper(), "Models");
return config.BuildSessionFactory();
}
示例12: GetConfiguration
public static Configuration GetConfiguration()
{
var configure = new Configuration();
configure.SessionFactoryName("NHibernateDB");
//Proxy扩展方法用于配置NHibernate延迟加载的字节码提供程序
configure.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>());
configure.DataBaseIntegration(db =>
{
db.Dialect<MsSql2005Dialect>();
db.Driver<SqlClientDriver>();
db.ConnectionString = _ConnectionString;
});
return configure;
}
示例13: BuildSessionFactory
private ISessionFactory BuildSessionFactory()
{
var configuration = new Configuration();
configuration.DataBaseIntegration(db =>
{
db.Dialect<MsSql2008Dialect>();
db.ConnectionStringName = "NHibernate_CRUD";
});
configuration.Properties[Environment.CurrentSessionContextClass]
= typeof(LazySessionContext).AssemblyQualifiedName;
configuration.Cache(c => c.UseQueryCache = false);
configuration.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>());
configuration.AddAssembly(GetType().Assembly);
return configuration.BuildSessionFactory();
}
示例14: Initialize
private static NHibernate.ISessionFactory Initialize(Action<ModelMapper> action)
{
var config = new Configuration();
config.Proxy(proxy => proxy.ProxyFactoryFactory<DefaultProxyFactoryFactory>());
config.DataBaseIntegration(db =>
{
db.Dialect<SQLiteDialect>();
db.ConnectionString = @"Data Source=|DataDirectory|\Test.db";
//db.Driver<SQLite20Driver>();
db.SchemaAction = SchemaAutoAction.Create;
db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
});
var mapper = new ModelMapper();
action(mapper);
var maps = mapper.CompileMappingForAllExplicitlyAddedEntities();
config.AddDeserializedMapping(maps, "Models");
return config.BuildSessionFactory();
}
示例15: Initialize
public static Configuration Initialize()
{
var configuration = new Configuration();
configuration
.Proxy(p => p.ProxyFactoryFactory<DefaultProxyFactoryFactory>())
.DataBaseIntegration(db =>
{
db.ConnectionStringName = "DevelopmentStack";
db.Dialect<MsSql2008Dialect>();
db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
})
.AddAssembly(typeof (Stack).Assembly)
.CurrentSessionContext<LazySessionContext>();
ConventionModelMapper mapper = new ConventionModelMapper();
mapper.WithConventions(configuration);
return configuration;
}