Map Property Int LEngth

12 views
Skip to first unread message

Yek MX

unread,
Oct 30, 2014, 10:44:15 PM10/30/14
to fluent-n...@googlegroups.com

Map(x => x.year).Column("year").Length(4).Not.Nullable();

In this maping not work length for int property
any solution?

Gleb Chermennov

unread,
Oct 31, 2014, 5:52:16 AM10/31/14
to fluent-n...@googlegroups.com
How do you expect this to behave? Length is only applicable to text columns - you know, nvarchar or whatever - when you can say "no longer than 100 characters". 
In case of integer, that just does not make sense.

mwpowellhtx

unread,
Nov 1, 2014, 8:52:11 AM11/1/14
to fluent-n...@googlegroups.com


On Friday, October 31, 2014 4:52:16 AM UTC-5, Gleb Chermennov wrote:
How do you expect this to behave? Length is only applicable to text columns - you know, nvarchar or whatever - when you can say "no longer than 100 characters". 
In case of integer, that just does not make sense.

This was my first thought as well: isn't that for xVARCHAR columns?

Gleb Chermennov

unread,
Nov 1, 2014, 10:57:39 AM11/1/14
to fluent-n...@googlegroups.com
On the other hand, if you make your year column nvarchar/text, you can set Length property, but then you'll have to handle conversions between String and Int :)

--
You received this message because you are subscribed to a topic in the Google Groups "Fluent NHibernate" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/fluent-nhibernate/uBYqoyixbH0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to fluent-nhibern...@googlegroups.com.
To post to this group, send email to fluent-n...@googlegroups.com.
Visit this group at http://groups.google.com/group/fluent-nhibernate.
For more options, visit https://groups.google.com/d/optout.



--
С уважением,
Чермённов Глеб

Yek MX

unread,
Nov 1, 2014, 4:35:32 PM11/1/14
to fluent-n...@googlegroups.com
thought it would be smart in some databases like mysql, the int fields can be assigned a length
like:
            Map(x => x.year).Column("year").CustomSqlType("Int(4)").Default(0).GeneratedBy.Assigned();

Gleb Chermennov

unread,
Nov 1, 2014, 7:19:06 PM11/1/14
to fluent-n...@googlegroups.com
I'm afraid that's up to NHibernate to interpret mapping in a particular way

--
You received this message because you are subscribed to a topic in the Google Groups "Fluent NHibernate" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/fluent-nhibernate/uBYqoyixbH0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to fluent-nhibern...@googlegroups.com.
To post to this group, send email to fluent-n...@googlegroups.com.
Visit this group at http://groups.google.com/group/fluent-nhibernate.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages