本文整理匯總了C#中NHibernate.Cfg.Configuration.AddFilterDefinition方法的典型用法代碼示例。如果您正苦於以下問題:C# Configuration.AddFilterDefinition方法的具體用法?C# Configuration.AddFilterDefinition怎麽用?C# Configuration.AddFilterDefinition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NHibernate.Cfg.Configuration
的用法示例。
在下文中一共展示了Configuration.AddFilterDefinition方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: NHibernateConfiguration
public static void NHibernateConfiguration(TestContext context)
{
log4net.Config.XmlConfigurator.Configure();
Configuration = new Configuration();
// lendo o arquivo hibernate.cfg.xml
Configuration.Configure();
FilterDefinition filterDef = new FilterDefinition(
"Empresa","EMPRESA = :EMPRESA",
new Dictionary<string, IType>() {{"EMPRESA", NHibernateUtil.Int32}}, false);
Configuration.AddFilterDefinition(filterDef);
filterDef = new FilterDefinition(
"Ativa", "ATIVO = 'Y'",
new Dictionary<string, IType>(), false);
Configuration.AddFilterDefinition(filterDef);
// Mapeamento por código
var mapper = new ModelMapper();
mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes());
HbmMapping mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();
Configuration.AddMapping(mapping);
// Gerar o XML a partir do mapeamento de codigo.
//var mappingXMl = mapping.AsString();
// Mapeamento por arquivo, in resource.
Configuration.AddAssembly(Assembly.GetExecutingAssembly());
// Gerando o SessionFactory
SessionFactory = Configuration.BuildSessionFactory();
}
示例2: ConfigurationFactory
public ConfigurationFactory(DatabaseSettings settings)
{
_configuration = new Configuration()
.SetInterceptor(new TenantIdInterceptor(settings.TenantId))
.DataBaseIntegration(db =>
{
db.ConnectionString = settings.ConnectionString;
db.Dialect<MsSql2012Dialect>();
db.BatchSize = 100;
});
_configuration
.AddFilterDefinition(new TenantIdDefinition(settings.TenantId));
var mapping = GetMappings();
_configuration.AddDeserializedMapping(mapping, "schema");
SchemaMetadataUpdater.QuoteTableAndColumns(_configuration);
new SchemaExport(_configuration).SetOutputFile(@"c:\temp\atxc_schema.ddl").Execute(false, false, false);
_sessionFactoryBuilder = _configuration.BuildSessionFactory();
}
示例3: GetConfiguration
public Configuration GetConfiguration()
{
var config = new Configuration();
string configName = "WebNHibernate.config".ToAbsolute();
config.Configure(configName);
var filterDef = new FilterDefinition(
cultureFilter,
null, // or your default condition
new Dictionary<string, IType> {{"cultureId", NHibernateUtil.String}},
false);
config.AddFilterDefinition(filterDef);
HbmMapping mapping = NHibernateMappingRepository.GetMappings();
config.AddDeserializedMapping(mapping, "NHSchemaTest");
SchemaMetadataUpdater.QuoteTableAndColumns(config);
return config;
}
示例4: InitializeFilters
private void InitializeFilters (Configuration cfg) {
var filterDef = new FilterDefinition (
"contextFilter",
null, // or your default condition
new Dictionary<string, IType> { { "current", NHibernateUtil.Int32 } },
false);
cfg.AddFilterDefinition (filterDef);
}