本文整理汇总了C#中PersistenceModel类的典型用法代码示例。如果您正苦于以下问题:C# PersistenceModel类的具体用法?C# PersistenceModel怎么用?C# PersistenceModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PersistenceModel类属于命名空间,在下文中一共展示了PersistenceModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ShouldAllowConventionsToAlterBiDirectionalTableNames
public void ShouldAllowConventionsToAlterBiDirectionalTableNames()
{
var model = new PersistenceModel();
var leftMap = new ClassMap<Left>();
leftMap.Id(x => x.Id);
leftMap.HasManyToMany(x => x.Rights);
var rightMap = new ClassMap<Right>();
rightMap.Id(x => x.Id);
rightMap.HasManyToMany(x => x.Lefts);
model.Add(leftMap);
model.Add(rightMap);
model.Conventions.Add<TestTableNameConvention>();
var mappings = model.BuildMappings();
var leftMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Left)).First();
var rightMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Right)).First();
leftMapping.Collections.First().TableName.ShouldEqual("Lefts_Rights");
rightMapping.Collections.First().TableName.ShouldEqual("Lefts_Rights");
}
开发者ID:heyitsanewb,项目名称:PokeWorld-Online,代码行数:25,代码来源:ManyToManyTableNameTests.cs
示例2: ShouldHaveSameTableNameForBothSidesOfMappingWhenRightSpecified
public void ShouldHaveSameTableNameForBothSidesOfMappingWhenRightSpecified()
{
var model = new PersistenceModel();
var leftMap = new ClassMap<Left>();
leftMap.Id(x => x.Id);
leftMap.HasManyToMany(x => x.Rights);
var rightMap = new ClassMap<Right>();
rightMap.Id(x => x.Id);
rightMap.HasManyToMany(x => x.Lefts)
.Table("MyJoinTable");
model.Add(leftMap);
model.Add(rightMap);
var mappings = model.BuildMappings();
var leftMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Left)).First();
var rightMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Right)).First();
leftMapping.Collections.First().TableName.ShouldEqual("MyJoinTable");
rightMapping.Collections.First().TableName.ShouldEqual("MyJoinTable");
}
开发者ID:nsreddy1986,项目名称:fluent-nhibernate,代码行数:25,代码来源:ManyToManyTableNameTests.cs
示例3: CreatePersistenceModel
public void CreatePersistenceModel()
{
conventionFinder = MockRepository.GenerateMock<IConventionFinder>();
model = new PersistenceModel(conventionFinder);
cfg = Fluently.Configure()
.Database(SQLiteConfiguration.Standard.InMemory)
.BuildConfiguration();
}
开发者ID:HudsonAkridge,项目名称:fluent-nhibernate,代码行数:9,代码来源:Configure.cs
示例4: CreatePersistenceModel
public void CreatePersistenceModel()
{
conventionFinder = MockRepository.GenerateMock<IConventionFinder>();
model = new PersistenceModel(conventionFinder);
TempDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
RemoveArtifacts();
Directory.CreateDirectory(TempDir);
}
开发者ID:HudsonAkridge,项目名称:fluent-nhibernate,代码行数:10,代码来源:WriteMappingsTo.cs
示例5: render_xml
private string render_xml(Action<PersistenceModel> addMappings)
{
var model = new PersistenceModel();
addMappings(model);
var mappings = model.BuildMappings();
var doc = new MappingXmlSerializer().Serialize(mappings.First());
return doc.OuterXml;
}
开发者ID:JamesKovacs,项目名称:fluent-nhibernate,代码行数:11,代码来源:ExternalComponentOutputSpecs.cs
示例6: establish_context
public override void establish_context()
{
var component_map = new ComponentMap<Component>();
component_map.Map(x => x.Property);
var class_map = new ClassMap<Target>();
class_map.Component(x => x.Component);
persistence_model = new PersistenceModel();
persistence_model.Add(class_map);
persistence_model.Add(component_map);
}
开发者ID:roend83,项目名称:fluent-nhibernate,代码行数:12,代码来源:ComponentMapSpecs.cs
示例7: ShouldntDuplicateJoinMapping
public void ShouldntDuplicateJoinMapping()
{
var model = new PersistenceModel();
var classMap = new ClassMap<Target>();
classMap.Id(x => x.Id);
classMap.Join("other", m => m.Map(x => x.Property));
model.Add(classMap);
model.Configure(cfg);
cfg.ClassMappings.First()
.JoinClosureIterator.Count().ShouldEqual(1);
}
开发者ID:heyitsanewb,项目名称:PokeWorld-Online,代码行数:14,代码来源:JoinPersistenceModelTests.cs
示例8: establish_context
public override void establish_context()
{
model = new PersistenceModel();
var comp_map = new ComponentMap<ComponentTarget>();
comp_map.Map(x => x.Property);
model.Add(comp_map);
var map = new ClassMap<Target>();
map.Id(x => x.Id);
map.Component(x => x.Component)
.ColumnPrefix(column_prefix);
model.Add(map);
}
开发者ID:oblivious,项目名称:Oblivious,代码行数:15,代码来源:ComponentColumnPrefixVisitorSpecs.cs
示例9: ShouldAllowOverridingOfDefaultInConventions
public void ShouldAllowOverridingOfDefaultInConventions()
{
var model = new PersistenceModel();
var map = new ClassMap<IdentityExamples>();
map.Id(x => x.Int);
model.Conventions.Add(new IdConvention());
model.Add(map);
var @class = model.BuildMappings()
.First()
.Classes.First();
((IdMapping)@class.Id).Generator.Class.ShouldEqual("increment");
}
开发者ID:garrisonx,项目名称:NH3BegginnersGuide,代码行数:16,代码来源:IdGeneratorTests.cs
示例10: SetUp
public void SetUp()
{
PersistenceModel model = new PersistenceModel();
model.Conventions.Add(new BackfieldAccessConvention());
model.Add(new CompositeIdModelMapping());
model.Add(new ManyToManyModelMapping());
model.Add(new ManyToOneModelMapping());
model.Add(new OneToOneModelMapping());
model.Add(new ParentModelMapping());
var classMappings = model.BuildMappings().SelectMany(x => x.Classes).ToDictionary(x => x.Type);
compositeId = classMappings[typeof(CompositeIdModel)];
manyToMany = classMappings[typeof(ManyToManyModel)];
manyToOne = classMappings[typeof(ManyToOneModel)];
oneToOne = classMappings[typeof(OneToOneModel)];
parent = classMappings[typeof(ParentModel)];
}
开发者ID:jjchoi,项目名称:fluent-nhibernate,代码行数:18,代码来源:AccessConventionTests.cs
示例11: ShouldAllowSettingOfKeyInConvention
public void ShouldAllowSettingOfKeyInConvention()
{
var model = new PersistenceModel();
var parent = new ClassMap<Parent>();
var child = new SubclassMap<Child>();
model.Add(parent);
model.Add(child);
model.Conventions.Add<SCKeyConvention>();
var subclass = model.BuildMappings()
.SelectMany(x => x.Classes)
.First()
.Subclasses.First();
((JoinedSubclassMapping)subclass).Key.Columns.First().Name.ShouldEqual("xxx");
((JoinedSubclassMapping)subclass).Key.Columns.Count().ShouldEqual(1);
}
开发者ID:JonKruger,项目名称:fluent-nhibernate,代码行数:19,代码来源:SubclassMapForJoinedSubclassConventionTests.cs
示例12: SetUp
public void SetUp()
{
var cfg = MsSqlConfiguration.MsSql2005
.ShowSql()
.ConnectionString.Is("Server=(local);initial catalog=nhibernate;Integrated Security=SSPI")
.ShowSql()
.ConfigureProperties(new Configuration());
var mappings = cfg.CreateMappings();
var dialect = new SQLiteDialect();
var model = new PersistenceModel();
model.Add(new PersonMap());
model.AddConvention(new NamingConvention());
var hibernateMapping = model.BuildHibernateMapping();
var classBinder = new RootClassBinder(mappings, dialect);
foreach (var mapping in hibernateMapping.Classes)
{
classBinder.Bind(mapping);
}
cfg.BuildMapping();
schemaExport = new SchemaExport(cfg);
}
开发者ID:paulbatum,项目名称:Fluent-NHibernate-Semantic-Model-Rewrite,代码行数:21,代码来源:SimpleClassTests.cs
示例13: ComponentWithPropertiesShouldAddToModelComponentsCollection
public void ComponentWithPropertiesShouldAddToModelComponentsCollection()
{
var classMap = new ClassMap<Parent>();
classMap.Id(x => x.Id);
var subclassMap = new SubclassMap<Child>();
subclassMap.Component(x => x.Component, c => c.Map(x => x.Name));
var model = new PersistenceModel();
model.Add(classMap);
model.Add(subclassMap);
model.BuildMappings()
.First()
.Classes.First()
.Subclasses.First()
.Components.Count().ShouldEqual(1);
}
开发者ID:sbakshi,项目名称:fluent-nhibernate,代码行数:21,代码来源:SubclassMapForSubclassSubPartModelGenerationTests.cs
示例14: SingleConnectionSessionSourceForSQLiteInMemoryTesting
public SingleConnectionSessionSourceForSQLiteInMemoryTesting(IDictionary<string, string> properties, PersistenceModel model) : base(properties, model)
{
}
开发者ID:nsreddy1986,项目名称:fluent-nhibernate,代码行数:3,代码来源:SingleConnectionSessionSourceForSQLiteInMemoryTesting.cs
示例15: MergeOutputShouldSetFlagOnFluentPersistenceModelsOnApply
public void MergeOutputShouldSetFlagOnFluentPersistenceModelsOnApply()
{
var model = new PersistenceModel();
mapping.UsePersistenceModel(model);
mapping.MergeMappings();
mapping.Apply(new Configuration());
model.MergeMappings.ShouldBeTrue();
}
开发者ID:garrisonx,项目名称:NH3BegginnersGuide,代码行数:10,代码来源:MappingConfigurationTests.cs
示例16: ShouldHaveSameTableNameForUniDirectionalMapping
public void ShouldHaveSameTableNameForUniDirectionalMapping()
{
var model = new PersistenceModel();
var leftMap = new ClassMap<Left>();
leftMap.Id(x => x.Id);
leftMap.HasManyToMany(x => x.Rights);
var rightMap = new ClassMap<Right>();
rightMap.Id(x => x.Id);
model.Add(leftMap);
model.Add(rightMap);
var mappings = model.BuildMappings();
var leftMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Left)).First();
leftMapping.Collections.First().TableName.ShouldEqual("RightToLeft");
}
开发者ID:heyitsanewb,项目名称:PokeWorld-Online,代码行数:21,代码来源:ManyToManyTableNameTests.cs
示例17: ShouldHaveSameTableNameForBothSidesOfMappingWhenHasMultipleBiDirectionalManyToManysOnSameEntities
public void ShouldHaveSameTableNameForBothSidesOfMappingWhenHasMultipleBiDirectionalManyToManysOnSameEntities()
{
var model = new PersistenceModel();
var leftMap = new ClassMap<Left>();
leftMap.Id(x => x.Id);
leftMap.HasManyToMany(x => x.Rights);
leftMap.HasManyToMany(x => x.SecondRights);
var rightMap = new ClassMap<Right>();
rightMap.Id(x => x.Id);
rightMap.HasManyToMany(x => x.Lefts);
rightMap.HasManyToMany(x => x.SecondLefts);
model.Add(leftMap);
model.Add(rightMap);
var mappings = model.BuildMappings();
var leftMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Left)).First();
var rightMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Right)).First();
leftMapping.Collections.First().TableName.ShouldEqual("LeftsToRights");
rightMapping.Collections.First().TableName.ShouldEqual("LeftsToRights");
leftMapping.Collections.ElementAt(1).TableName.ShouldEqual("SecondLeftsToSecondRights");
rightMapping.Collections.ElementAt(1).TableName.ShouldEqual("SecondLeftsToSecondRights");
}
开发者ID:heyitsanewb,项目名称:PokeWorld-Online,代码行数:29,代码来源:ManyToManyTableNameTests.cs
示例18: CreatePersistenceModel
public void CreatePersistenceModel()
{
conventionFinder = MockRepository.GenerateMock<IConventionFinder>();
model = new PersistenceModel(conventionFinder);
}
开发者ID:HudsonAkridge,项目名称:fluent-nhibernate,代码行数:5,代码来源:OnConstruction.cs
示例19: Where
private string Where(string where)
{
var classMap = new ClassMap<Target>();
classMap.Id(x => x.Id);
classMap.HasMany(x => x.Children)
.Where(where);
var model = new PersistenceModel();
model.Add(classMap);
return model.BuildMappings()
.First()
.Classes.First()
.Collections.First()
.Where;
}
开发者ID:roelofb,项目名称:fluent-nhibernate,代码行数:17,代码来源:WhereTests.cs
示例20: CreatePersistenceModel
public void CreatePersistenceModel()
{
model = new PersistenceModel();
model.Conventions.Add<TestForeignKeyConvention>();
}
开发者ID:AndyStewart,项目名称:fluent-nhibernate,代码行数:5,代码来源:ForeignKeyConventionTests.cs
注:本文中的PersistenceModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论