本文整理汇总了C#中ObjectRelationalMapper.TablePerClass方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectRelationalMapper.TablePerClass方法的具体用法?C# ObjectRelationalMapper.TablePerClass怎么用?C# ObjectRelationalMapper.TablePerClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectRelationalMapper
的用法示例。
在下文中一共展示了ObjectRelationalMapper.TablePerClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComposingPatternsAppliersPacks
public void ComposingPatternsAppliersPacks()
{
// Thanks to Lorenzo Vegetti to provide the domain of this example.
// This example refers to a little-domain, interesting from the point of view of mapping with ConfORM.
// Here you can see how apply general convetion, how and when compose patterns-appliers-packs and patterns-appliers,
// how ConfORM can apply different mapping depending on the type of enum (see the difference on CostOptions) and so on...
// You don't have to organize the mapping all in one class, as in this example, and you don't have to use the IModuleMapping...
// You can organize the mapping as you feel more confortable for your application; in some case a class is enough, in other cases would
// be better the separation per module/concern, you are not closed in "mapping per class" box.
var orm = new ObjectRelationalMapper();
// With the follow line I'm adding the pattern for the POID strategy ("native" instead the default "High-Low")
orm.Patterns.PoidStrategies.Add(new NativePoidPattern());
// composition of patterns-appliers-packs and patterns-appliers for Lorenzo's domain
// Note: for bidirectional-one-to-many association Lorenzo is not interested in the default cascade behavior,
// implemented in the BidirectionalOneToManyRelationPack, because he is using a sort of soft-delete in his base class VersionModelBase.
// He can implements a custom pack of patterns-appliers to manage the situation when classes does not inherits from VersionModelBase by the way
// he don't want the cascade atall, so the BidirectionalOneToManyInverseApplier will be enough
IPatternsAppliersHolder patternsAppliers =
(new SafePropertyAccessorPack())
.Merge(new OneToOneRelationPack(orm))
.Merge(new BidirectionalManyToManyRelationPack(orm))
.Merge(new DiscriminatorValueAsClassNamePack(orm))
.Merge(new CoolColumnsNamingPack(orm))
.Merge(new TablePerClassPack())
.Merge(new PluralizedTablesPack(orm, new EnglishInflector()))
.Merge(new ListIndexAsPropertyPosColumnNameApplier())
.Merge(new BidirectionalOneToManyInverseApplier(orm))
.Merge(new EnumAsStringPack())
.Merge(new DatePropertyByNameApplier())
.Merge(new MsSQL2008DateTimeApplier());
// Instancing the Mapper using the result of Merge
var mapper = new Mapper(orm, patternsAppliers);
// Setting the version property using the base class
orm.VersionProperty<VersionModelBase>(v => v.Version);
// Note: I'm declaring the strategy only for the base entity
orm.TablePerClassHierarchy<Cost>();
orm.TablePerClass<EditionQuotation>();
orm.TablePerClass<ProductQuotation>();
orm.TablePerClass<Quotation>();
AppliesGeneralConventions(mapper);
// EditionQuotation.PrintCost don't use lazy-loading
mapper.Customize<EditionQuotation>(map => map.ManyToOne(eq => eq.PrintCost, m2o => m2o.Lazy(LazyRelation.NoLazy)));
// Customizes some others DDL's stuff outside conventions
CustomizeColumns(mapper);
// Note : I have to create mappings for the whole domain
HbmMapping mapping =
mapper.CompileMappingFor(
typeof (GenericModelBase<>).Assembly.GetTypes().Where(t => t.Namespace == typeof (GenericModelBase<>).Namespace));
Console.Write(mapping.AsString());
}
示例2: CreateMapping
public HbmMapping CreateMapping()
{
var orm = new ObjectRelationalMapper();
//主键生成策略(自增)
orm.Patterns.PoidStrategies.Add(new NativePoidPattern());
var entities = new[]
{
typeof(User),
typeof(PlusMaterial),
typeof(StockIn),
typeof(StockInDetail),
typeof(StockOut),
typeof(StockOutDetail),
};
orm.TablePerClass(entities);
//关系映射
orm.ManyToOne<StockInDetail, StockIn>();
orm.ManyToOne<StockOutDetail, StockOut>();
//数据库命名规则
var mapper = new Mapper(orm, new CoolPatternsAppliersHolder(orm));
orm.TablePerClass(entities);
var hc = mapper.CompileMappingFor(Assembly.Load("PMMS.Entities").GetTypes());
return hc;
}
示例3: DefiningAndCustomizingVersionThroughBaseImplementation
public void DefiningAndCustomizingVersionThroughBaseImplementation()
{
// In this example I'll show how you can work with Version and how ConfORM understands OOP
var orm = new ObjectRelationalMapper();
var mapper = new Mapper(orm, new CoolPatternsAppliersHolder(orm));
// In this case I will use the definition of table-to-class strategy class by class
orm.TablePerClass<CurrencyDefinition>();
orm.TablePerClass<Company>();
orm.TablePerClass<Customer>();
orm.TablePerClass<Provider>();
// Defining relations
orm.OneToOne<Company, Customer>();
orm.OneToOne<Company, Provider>();
// In the follow line I'm defining which is the property used as Version for all classes inherited from VersionedEntity
orm.VersionProperty<VersionedEntity>(ve=> ve.Version);
// In the follow line I'm customizing the column-name for the property used as Version for all classes inherited from VersionedEntity....
// Note : VersionedEntity is not an entity, it is only a base class.
mapper.Class<VersionedEntity>(cm => cm.Version(ve => ve.Version, vm => vm.Column("Revision")));
// In the follow line I'm customizing the column-name for the property used as Version only for the class Provider
// Note : You can move the follow line before the previous and the result does not change, this is because ConfORM can understand
// which is a base customization and which is the specific customization.
mapper.Class<Provider>(cm => cm.Version(ve => ve.Version, vm => vm.Column("IncrementalVersion")));
// Note : I have to create mappings for the whole domain; Entity and VersionedEntity are excluded from de mapping because out-side
// root-entities hierarchy (root-entities are : CurrencyDefinition, Company, Customer, Provider)
var mapping = mapper.CompileMappingFor(typeof(Entity).Assembly.GetTypes().Where(t => t.Namespace == typeof(Entity).Namespace));
Console.Write(mapping.AsString());
}
示例4: WhenNotRegisteredAsManyToOneRecognizeRelation
public void WhenNotRegisteredAsManyToOneRecognizeRelation()
{
var mapper = new ObjectRelationalMapper();
mapper.TablePerClass<AEntity>();
mapper.TablePerClass<BEntity>();
mapper.IsOneToMany(typeof(BEntity), typeof(AEntity)).Should().Be.True();
mapper.IsManyToOne(typeof(AEntity), typeof(BEntity)).Should().Be.True();
}
示例5: WhenExplicitRegisteredRecognizeInverseRelation
public void WhenExplicitRegisteredRecognizeInverseRelation()
{
var mapper = new ObjectRelationalMapper();
mapper.TablePerClass<AEntity>();
mapper.TablePerClass<BEntity>();
mapper.ManyToOne<AEntity, BEntity>();
mapper.IsOneToMany(typeof(BEntity), typeof(AEntity)).Should().Be.True();
}
示例6: RecognizeOneToMany
public void RecognizeOneToMany()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<Parent>();
orm.TablePerClass<Image>();
orm.IsOneToMany(typeof (Child), typeof (Image)).Should().Be.True();
}
示例7: WhenExplicitRegisteredRecognizeRelation
public void WhenExplicitRegisteredRecognizeRelation()
{
var mapper = new ObjectRelationalMapper();
mapper.TablePerClass<User>();
mapper.TablePerClass<Person>();
mapper.OneToOne<User, Person>();
mapper.IsOneToOne(typeof(User), typeof(Person)).Should().Be.True();
}
示例8: WhenExplicitRegisteredRecognizeInverseRelationAsImplicit
public void WhenExplicitRegisteredRecognizeInverseRelationAsImplicit()
{
var mapper = new ObjectRelationalMapper();
mapper.TablePerClass<User>();
mapper.TablePerClass<Person>();
mapper.OneToOne<User, Person>();
mapper.IsMasterOneToOne(typeof(Person), typeof(User)).Should().Be.False();
}
示例9: WhenFindInterfaceForRootClassThenRecognizeRelation
public void WhenFindInterfaceForRootClassThenRecognizeRelation()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<Contact>();
orm.TablePerClass<UserGroup>();
orm.ManyToOne<UserGroup, ISecurity>();
orm.IsManyToOne(typeof (UserGroup), typeof (ISecurity)).Should().Be.True();
}
示例10: CanDiscoverManyToOneFromComponentToEntity
public void CanDiscoverManyToOneFromComponentToEntity()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<AEntity>();
orm.TablePerClass<BEntity>();
orm.Component<AComponent>();
orm.IsManyToOne(typeof(AComponent), typeof(BEntity)).Should().Be.True();
}
示例11: DomainDefinition
public void DomainDefinition(ObjectRelationalMapper orm)
{
orm.TablePerClass<Animal>();
orm.TablePerClass<User>();
orm.TablePerClass<StateProvince>();
orm.TablePerClassHierarchy<Zoo>();
orm.ManyToMany<Human, Human>();
orm.OneToOne<User, Human>();
}
示例12: IntegrationWithObjectRelationalMapper
public void IntegrationWithObjectRelationalMapper()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<AEntity>();
orm.TablePerClass<BEntity>();
orm.ManyToOne<AEntity, BEntity>();
HbmMapping mapping = GetMapping(orm);
VerifyAEntityMapping(mapping);
}
示例13: IntegrationWithObjectRelationalMapper
public void IntegrationWithObjectRelationalMapper()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<Person>();
orm.TablePerClass<Animal>();
orm.ManyToMany<Person, Animal>();
HbmMapping mapping = GetMapping(orm);
VerifyMapping(mapping);
}
示例14: IntegrationWithObjectRelationalMapper
public void IntegrationWithObjectRelationalMapper()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<Parent>();
orm.TablePerClass<Child>();
orm.ManyToOne<Child, Parent>();
HbmMapping mapping = GetMapping(orm);
VerifyMapping(mapping);
}
示例15: WhenExplicitRegisteredAsOneToOneNotRecognizeRelation
public void WhenExplicitRegisteredAsOneToOneNotRecognizeRelation()
{
var mapper = new ObjectRelationalMapper();
mapper.TablePerClass<AEntity>();
mapper.TablePerClass<BEntity>();
mapper.OneToOne<AEntity, BEntity>();
mapper.IsOneToMany(typeof(BEntity), typeof(AEntity)).Should().Be.False();
// the default behaviour map an unidirectional one-to-one as a many-to-one (for NHibernate)
// mapper.IsManyToOne(typeof(AEntity), typeof(BEntity)).Should().Be.False();
}