本文整理汇总了C#中AutoPersistenceModel类的典型用法代码示例。如果您正苦于以下问题:C# AutoPersistenceModel类的具体用法?C# AutoPersistenceModel怎么用?C# AutoPersistenceModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AutoPersistenceModel类属于命名空间,在下文中一共展示了AutoPersistenceModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例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);
}
示例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)"));
}
示例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());
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
}
示例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();
}
示例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;
}