本文整理汇总了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);
}