Ciel
Ciel

Reputation: 17772

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 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.

Upvotes: 0

Views: 393

Answers (2)

Madhivanan
Madhivanan

Reputation: 13700

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

Upvotes: 0

Related Questions