Fluent NHibernate 对于不同的基本类型有不同的约定
目前,我们将所有实体和映射保留在同一个程序集中。我们的实体派生自一个基本类 Entity,它是一个 EntityWithTypedId
此外,我们还有一个表名约定,告诉您将表名复数化。
现在我想创建另外两个基本类型 eq AggregateRootEntity 和 AggregateEntity,它们都派生自 Entity。 我想为两个基本实体创建两组约定:
比方说: 对于从 AggregateRootEntity 表派生的所有实体,应以“ag_”为前缀,并且 Id 是增量生成的,但对于从 AggregateEntity 表派生的所有实体,应以“a_”为前缀,并应分配 Id。
是否可以根据某些条件设定约定?
At this moment we are keeping all Entities and Mappings into same assembly. Our entities derived from a basic class Entity which is an EntityWithTypedId
Also we are having a table name Convention telling to pluralize the table names.
Now I want to create other two base types e.q. AggregateRootEntity and AggregateEntity, both derive from Entity.
And I would like to create two set of conventions for both base entities:
Let's say:
For for all entities derived from AggregateRootEntity tables should be prefixed with "ag_" and Id is incremental generated, but for all entities derived from AggregateEntity tables should be prefixed with "a_" and Ids should be assigned.
Is it possible to Set Conventions based on some conditions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用多个约定来完成此操作,每个约定都在其 Accept 方法中检查特定类型
,例如:
Just a block of code out of the FNH Wiki
http://wiki. Fluentnhibernate.org/Acceptance_criteria
You can do it with multiple conventions, each checking for a specific type in their Accept methods
something like:
Just a block of code out of the FNH Wiki
http://wiki.fluentnhibernate.org/Acceptance_criteria