Fluent NHibernate:如何更改自动映射字符串集合的底层 sql 类型?
我有一堂课:
public class ParentClass
{
//other stuff
IList<string> ChildPages
}
当 'IList
' 通过 Fluent NHibernate 自动映射,使用 nvarchar(255)< 创建“
ChildPages
”连接表/code> 集合中每个字符串的支持字段。
但问题是我希望 sql 支持字段为“text
”,这样我就可以为该实体提供冗长的条目。
进行此更改的最简单方法是什么?
如何更改自动映射的原始集合的基础类型?
另外,为了额外的好处,您将如何通过约定或映射覆盖来做到这一点?
谢谢!
I have a class:
public class ParentClass
{
//other stuff
IList<string> ChildPages
}
When 'IList<string> ChildPages
' gets automapped by Fluent NHibernate a 'ChildPages
' join table is created with a nvarchar(255)
backing field for each string in the collection.
But the problem is that I want the sql backing field to be 'text
', so that I can have lengthy entries for this entity.
What's the easiest way to make this change?
How do you change the underlying type of automapped primitive collections?
Also, for extra points, how would you do this with a convention or mapping overrides?
Thx!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以设置覆盖约定,以便字符串使用
text
而不是nvarchar2 (255)
,如解决方案 在另一个线程上。如果您只希望特定属性有这样的行为,那么在您的流畅配置中类似这样的东西就可以工作:You can setup an override convention so that strings use
text
instead ofnvarchar2 (255)
, as shown in the solution on this other thread. If you only want such behavior for a specific property, something like this in your fluent configuration would work: