Fluent NHibernate/MSSQL 中关于 nvarchar(MAX) 的混淆
我一直在寻找使用 Fluent nHibernate 存储大字符串值(例如博客文章或文本描述等)的最佳方法,我不断看到的答案是使用nvarchar(MAX)
。如果我的读数正确(通常情况并非如此),则为 4000+。所以我有一个像这样的字段...
Map(x => x.Description)
.Column("[description]")
.Length(4001)
.Access.Property()
.Not.Nullable();
理论上,这应该可以,对吧?不过我对此有点困惑。在学校里,我们被非常清楚地教导说,要使每个列的大小尽可能小。
如果我将该列设置为最大大小,这是否会违反该原则并使表变得非常大且浪费?谁能给我讲一些非常清晰、愚蠢、不适合金发的逻辑吗?整个磨难让我感到很困惑。
I've been looking around for the best way to store a large string value (like a blog post, or a text description, etc.) with Fluent nHibernate
and the answer I keep seeing is to use an nvarchar(MAX)
. Which, if my reading is correct (which it very often isn't) is 4000+. So I have a field like so...
Map(x => x.Description)
.Column("[description]")
.Length(4001)
.Access.Property()
.Not.Nullable();
In theory, this should do it, right? I'm a little confused about this though. In school, we were taught pretty clearly that you want to make each column size as small as possible.
If I make that column max
size, doesn't that go against that very principle and make the table very large, and wasteful? Can anyone shed some very clear, stupid, blonde-proof logic on this for me? I've been left with a lot of confusion over the whole ordeal.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看这个,也许会有帮助: http://www.crankingoutcode.com/post/Storing-large-strings-with-Fluent-NHibernate-(automapping).aspx
并且陷阱:http://ayende.com/blog/1969/nhibernate -和大文本字段陷阱
Have a look at this, maybe be it will help: http://www.crankingoutcode.com/post/Storing-large-strings-with-Fluent-NHibernate-(automapping).aspx
And Gotcha's: http://ayende.com/blog/1969/nhibernate-and-large-text-fields-gotchas
请注意,max 表示您最多可以存储 2^31-1 字节数据的字符。但是它会根据数据的实际长度消耗空间
Note that max means that you can store characters upto 2^31-1 bytes of data. However it will consume space based on the actual length of the data