Confusion about nvarchar(MAX) in Fluent NHibernate/MSSQL
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 nHibe开发者_JAVA技巧rnate
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.
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
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
精彩评论