本文整理汇总了C#中AutoPersistenceModel类的典型用法代码示例。如果您正苦于以下问题:C# AutoPersistenceModel类的具体用法?C# AutoPersistenceModel怎么用?C# AutoPersistenceModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AutoPersistenceModel类属于命名空间,在下文中一共展示了AutoPersistenceModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetSessionFactory
public static ISessionFactory GetSessionFactory(NhDataContext context, FluentConfiguration factoryConfig, AutoPersistenceModel autoPersistanceModel = null)
{
var contextType = context.GetType();
var contextAssembly = Assembly.GetAssembly(contextType);
return _factories.GetOrAdd(contextType, CreateSessionFactory(contextAssembly, factoryConfig, autoPersistanceModel));
}
开发者ID:OgaFuuu,项目名称:BootSharp,代码行数:7,代码来源:NhHelper.cs
示例2: CreateSessionFactory
private static ISessionFactory CreateSessionFactory(Assembly contextAssembly, IPersistenceConfigurer dbPersister, AutoPersistenceModel autoPersistanceModel = null)
{
// Create config
var factoryConfig = Fluently.Configure();
factoryConfig.Database(dbPersister);
return CreateSessionFactory(contextAssembly, factoryConfig, autoPersistanceModel);
}
开发者ID:OgaFuuu,项目名称:BootSharp,代码行数:7,代码来源:NhHelper.cs
示例3: AdditionalModelConfig
protected virtual void AdditionalModelConfig(AutoPersistenceModel model)
{
// 29.12.2011 - Who would have thought that apparently only know I managed to surpass 4000 chars.
// seems crazy but anyways, here's a fix for NH cutting off my text
model.Override<Content>(
a => a.Map(c => c.Body).Length(4001).CustomSqlType("nvarchar(MAX)"));
}
开发者ID:flq,项目名称:Rf.Sites,代码行数:7,代码来源:SessionFactoryMaker.cs
示例4: MyAutoPersistenceModel
public MyAutoPersistenceModel()
{
this.AutoPersistenceModel = AutoMap.AssemblyOf<Entity>(new CustomAutomappingConfiguration())
.IgnoreBase<Entity>()
.Override<User>(map => map.IgnoreProperty(x => x.DisplayedName))
.Override<Appointment>(map => map.IgnoreProperty(x => x.DateRange))
.Override<IllnessPeriod>(map => map.IgnoreProperty(p => p.Duration))
.Override<Role>(map => map.HasManyToMany(x => x.Tasks).Cascade.All())
.Override<DbSetting>(map => map.Map(p => p.Key).Unique())
.Override<Patient>(map =>
{
map.DynamicUpdate();
map.IgnoreProperty(x => x.Age);
map.Map(x => x.IsDeactivated).Default("0").Not.Nullable();
map.HasMany<Bmi>(x => x.BmiHistory).KeyColumn("Patient_Id");
map.HasMany<MedicalRecord>(x => x.MedicalRecords).KeyColumn("Patient_Id");
map.HasMany<IllnessPeriod>(x => x.IllnessHistory).KeyColumn("Patient_Id");
map.HasMany<Appointment>(x => x.Appointments).KeyColumn("Patient_Id");
})
.Override<Person>(map =>
{
map.Map(p => p.FirstName).Index("idx_person_FirstName");
map.Map(p => p.LastName).Index("idx_person_LastName");
})
.Override<ApplicationStatistics>(map =>
{
map.Map(e => e.IsExported).Default("0").Not.Nullable();
map.Map(e => e.Version).Default("\"3.0.3\"").Not.Nullable();
})
.Conventions.Add(DefaultCascade.SaveUpdate()
, DynamicUpdate.AlwaysTrue()
, DynamicInsert.AlwaysTrue()
, LazyLoad.Always());
}
开发者ID:seniorOtaka,项目名称:ndoctor,代码行数:34,代码来源:MyAutoPersistenceModel.cs
示例5: SagaPersistenceModel
public static AutoPersistenceModel SagaPersistenceModel(IEnumerable<Type> typesToScan)
{
var sagaEntites = typesToScan.Where(t => typeof(ISagaEntity).IsAssignableFrom(t) && !t.IsInterface);
var model = new AutoPersistenceModel();
model.Conventions.AddFromAssemblyOf<IdShouldBeAssignedConvention>();
var entityTypes = GetTypesThatShouldBeAutoMapped(sagaEntites,typesToScan);
var assembliesContainingSagas = sagaEntites.Select(t => t.Assembly).Distinct();
foreach (var assembly in assembliesContainingSagas)
model.AddEntityAssembly(assembly)
.Where(t => entityTypes.Contains(t));
var componentTypes = GetTypesThatShouldBeMappedAsComponents(sagaEntites);
model.Setup(s =>
{
s.IsComponentType =
type => componentTypes.Contains(type);
});
return model;
}
开发者ID:togakangaroo,项目名称:NServiceBus,代码行数:25,代码来源:Create.cs
示例6: Init
public static Configuration Init(
ISessionStorage storage,
string[] mappingAssemblies,
AutoPersistenceModel autoPersistenceModel,
string cfgFile,
string validatorCfgFile)
{
return Init(storage, mappingAssemblies, autoPersistenceModel, cfgFile, null, validatorCfgFile, null);
}
开发者ID:EdisonCP,项目名称:sharp-architecture,代码行数:9,代码来源:NHibernateSession.cs
示例7: Generate
public AutoPersistenceModel Generate()
{
var mappings = new AutoPersistenceModel();
mappings.AddEntityAssembly(typeof (Class1).Assembly).Where(GetAutoMappingFilter);
mappings.Conventions.Setup(GetConventions());
mappings.Setup(GetSetup());
mappings.UseOverridesFromAssemblyOf<AutoPersistenceModelGenerator>();
return mappings;
}
开发者ID:jhollingworth,项目名称:Hedgehog,代码行数:9,代码来源:AutoPersistenceModelGenerator.cs
示例8: Generate
public AutoPersistenceModel Generate()
{
var mappings = new AutoPersistenceModel();
mappings.AddEntityAssembly(typeof(Site).Assembly).Where(GetAutoMappingFilter);
// mappings.Setup(GetSetup());
mappings.IgnoreBase<Entity>();
mappings.IgnoreBase(typeof(EntityWithTypedId<>));
mappings.UseOverridesFromAssemblyOf<AutoPersistenceModelGenerator>();
return mappings;
}
开发者ID:fudder,项目名称:cs493,代码行数:10,代码来源:AutoPersistenceModelGenerator.cs
示例9: VerifyMapping
private void VerifyMapping(AutoPersistenceModel model, Action<CompositeIdMapping> verifier)
{
var idMapping = model.BuildMappings()
.First()
.Classes
.First()
.Id
;
idMapping.ShouldBeOfType(typeof(CompositeIdMapping));
verifier((CompositeIdMapping)idMapping);
}
开发者ID:jjchoi,项目名称:fluent-nhibernate,代码行数:12,代码来源:CompositeIdOverrides.cs
示例10: Generate
public Configuration Generate()
{
var model = new AutoPersistenceModel()
.AddEntityAssembly(Assembly.GetExecutingAssembly())
.Where(x => x.Namespace.IsNotNullOrEmpty() && x.Namespace.StartsWith("FakeVader.Core.Domain"))
.Conventions.AddFromAssemblyOf<HasManyConvention>();
return Fluently.Configure()
.Database(databaseConfig)
.Mappings(
configuration => configuration.AutoMappings.Add(model)
).BuildConfiguration();
}
开发者ID:JamesKovacs,项目名称:prairiedevcon2010-jquerydojo,代码行数:12,代码来源:NHibernateMappingGenerator.cs
示例11: Generate
public AutoPersistenceModel Generate()
{
var mappings = new AutoPersistenceModel();
mappings.AddEntityAssembly(typeof (Class1).Assembly).Where(GetAutoMappingFilter);
mappings.Conventions.Setup(GetConventions());
mappings.Setup(GetSetup());
mappings.UseOverridesFromAssemblyOf<AutoPersistenceModelGenerator>();
mappings.Override<Idea>(i => i.Map(m => m.Text).CustomSqlType("TEXT"));
mappings.Override<Comment>(c => c.Map(m => m.Text).CustomSqlType("TEXT"));
return mappings;
}
开发者ID:jhollingworth,项目名称:ideas,代码行数:14,代码来源:AutoPersistenceModelGenerator.cs
示例12: Generate
public AutoPersistenceModel Generate()
{
var mappings = new AutoPersistenceModel();
mappings
.AddEntityAssembly(typeof(Player).Assembly)
.UseOverridesFromAssembly(typeof(AutoPersistenceModelGenerator).Assembly)
.Where(GetAutoMappingFilter);
//.Setup(GetSetup())
//.Conventions.Setup(GetConventions);
MapEnums(mappings);
return mappings;
}
开发者ID:MikeHook,项目名称:FootyLinks,代码行数:15,代码来源:AutoPersistenceModelGenerator.cs
示例13: Alter
public void Alter(AutoPersistenceModel model)
{
// if any type has a property of this type
// that is of a type (or has a collection of a type)
// that is abstract
// is not generic
// and inherits from entity
// and has inheritors in the domain
// then include that type
// foreach property in type
foreach (var strategyType in Strategies())
{
model.IncludeBase(strategyType);
}
}
开发者ID:bibliopedia,项目名称:bibliopedia,代码行数:15,代码来源:AutoDetectStrategies.cs
示例14: fup
public virtual void fup()
{
domainModel = new AutoPersistenceModel(new AutoMapConfig())
.AddEntityAssembly(Assembly.GetAssembly(typeof(IEntity)))
.UseOverridesFromAssemblyOf<AirplayAutoMap>();
var dbConfig = SQLiteConfiguration.Standard.UsingFile("gema4").ShowSql();
//var dbConfig = SQLiteConfiguration.Standard.UsingFile("gema4");
cfg = Fluently.Configure()
.Mappings(m => m.AutoMappings.Add(domainModel))
.Database(dbConfig)
.BuildConfiguration();
sf = cfg.BuildSessionFactory();
}
开发者ID:bjornebjornson,项目名称:gema2010,代码行数:16,代码来源:ADataFix.cs
示例15: Generate
public AutoPersistenceModel Generate()
{
var mappings = new AutoPersistenceModel();
mappings = AutoMap.AssemblyOf<Domain.Entity>();
mappings.Where(GetAutoMappingFilter);
mappings.Conventions.Setup(GetConventions());
mappings.UseOverridesFromAssemblyOf<AutoPersistenceModelGenerator>();
mappings.Setup(GetSetup());
mappings.OverrideAll(x => x.IgnoreProperties(z => z.PropertyType.IsSubclassOf(typeof(Enumeration))));
mappings.IgnoreBase<Domain.Entity>();
mappings.UseOverridesFromAssemblyOf<AutoPersistenceModelGenerator>();
return mappings;
}
开发者ID:rauhryan,项目名称:warmup-templates,代码行数:16,代码来源:AutoPersistenceModelGenerator.cs
示例16: Alter
/// <summary>
/// Alter the model
/// </summary>
/// <remarks>
/// Finds all types in the assembly (passed in the constructor) that implement IAutoMappingOverride<T>, then
/// creates an AutoMapping<T> and applies the override to it.
/// </remarks>
/// <param name="model">AutoPersistenceModel instance to alter</param>
public void Alter(AutoPersistenceModel model)
{
// find all types deriving from IAutoMappingOverride<T>
var types = from type in assembly.GetExportedTypes()
where !type.IsAbstract
let entity = (from interfaceType in type.GetInterfaces()
where interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == typeof(IAutoMappingOverride<>)
select interfaceType.GetGenericArguments()[0]).FirstOrDefault()
where entity != null
select type;
foreach (var type in types)
{
model.Override(type);
}
}
开发者ID:akhuang,项目名称:NHibernateTest,代码行数:24,代码来源:AutoMappingOverrideAlteration.cs
示例17: create
static ISessionFactory create()
{
var domainModel = new AutoPersistenceModel(new AutoMapConfig())
.AddEntityAssembly(Assembly.GetAssembly(typeof(IEntity)))
.UseOverridesFromAssemblyOf<AirplayAutoMap>();
var sqlite = SQLiteConfiguration.Standard
.ConnectionString(x => x.Is("Data Source=|DataDirectory|gema4"))
.CurrentSessionContext("web");
var _sf = Fluently.Configure()
.Mappings(m => m.AutoMappings.Add(domainModel))
.Database(sqlite)
.BuildSessionFactory();
return _sf;
}
开发者ID:bjornebjornson,项目名称:gema2010,代码行数:16,代码来源:NhManager.cs
示例18: GetSessionFactory
public ISessionFactory GetSessionFactory(string connection)
{
var model = new AutoPersistenceModel()
.AddEntityAssembly(typeof(Product).Assembly)
.Where(t => t.Namespace.StartsWith(typeof(Product).Namespace))
.Conventions.AddFromAssemblyOf<TableNameConvention>()
.UseOverridesFromAssemblyOf<CartMapOverride>();
ISessionFactory fluentConfiguration = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2012
.ConnectionString(c => c.FromConnectionStringWithKey(connection))
.ShowSql())
.Mappings(m => m.AutoMappings.Add(model))
.BuildSessionFactory();
return fluentConfiguration;
}
开发者ID:catirado,项目名称:SPE-Store,代码行数:17,代码来源:NhibernateSessionFactory.cs
示例19: NHibernatePersistenceModel
public NHibernatePersistenceModel()
{
_autoPersistenceModel = AutoPersistenceModel
.MapEntitiesFromAssemblyOf<DomainEntity>()
.WithAlterations(x =>
x.Add<AutoMappingAlteration>())
.WithSetup(s =>
{
s.FindIdentity = type => type.Name == "ID";
s.IsBaseType = type => type == typeof (DomainEntity);
})
//.Where(type =>
// typeof (DomainEntity).IsAssignableFrom(type) &&
// type.Namespace == "Fohjin.Core.Domain")
.ConventionDiscovery
.AddFromAssemblyOf<IdentityColumnConvention>()
.UseOverridesFromAssemblyOf<UserMappingOverride>();
}
开发者ID:Anupam-,项目名称:fubumvc-contrib,代码行数:18,代码来源:NHibernatePersistenceModel.cs
示例20: BuildPersistenceModel
public AutoPersistenceModel BuildPersistenceModel()
{
var persistenceModel = new AutoPersistenceModel();
persistenceModel.Conventions.Setup(c =>
{
c.Add(typeof(ForeignKeyNameConvention));
c.Add(typeof(ReferenceConvention));
c.Add(typeof(PrimaryKeyNameConvention));
c.Add(typeof(TableNameConvention));
});
persistenceModel.AddMappingsFromAssembly(AssemblyMapper);
persistenceModel.WriteMappingsTo(@"./");
return persistenceModel;
}
开发者ID:thangchung,项目名称:NHibernate3Sample,代码行数:18,代码来源:NHibernateComponentModule.cs
注:本文中的AutoPersistenceModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论