Map By Code and default value

27 views
Skip to first unread message

dwlodarczyk

unread,
Jul 29, 2011, 9:10:45 AM7/29/11
to nhusers
Hi,

How to map Default Value for property/field when using Map By Code?

For example this:

<property name="TermService" type="System.Boolean">
<column name="TermService" not-null="true" default="0" />
</property>

using map by code is?

best regards

Neo

unread,
Jul 29, 2011, 9:57:18 AM7/29/11
to nhusers
something like this:
mapper.Class<MyDomainObject>(map => map.Property(s => s.TermService,
pm => pm.Column(cm => cm.Default(0))));

I noticed however that if you want to set the default value of a
string property you need to escape the string twice i.e:
cm.Default("'my default value'")

dwlodarczyk

unread,
Jul 29, 2011, 10:10:20 AM7/29/11
to nhusers
Thanks :)
I don't see this possibility in map.Property and forget to look into
pm.Column

best regards

Fabio Maulo

unread,
Jul 30, 2011, 11:27:08 AM7/30/11
to nhu...@googlegroups.com
Neo,
can you file a JIRA ticket about the need of double-quote ?
thanks.

Neo

unread,
Jul 30, 2011, 3:12:01 PM7/30/11
to nhusers
Done:
https://nhibernate.jira.com/browse/NH-2815

I haven't attached any test case for this issue.
For future reference, is there any document describing how you would
like a failing test case to be outlined for bugs in the nhibernate
jira?

Cheers!

sbohlen

unread,
Jul 31, 2011, 11:21:08 AM7/31/11
to nhu...@googlegroups.com

Fabio Maulo

unread,
Jul 31, 2011, 6:10:20 PM7/31/11
to nhu...@googlegroups.com
btw it is not a bug, just an improv.

Neo

unread,
Aug 1, 2011, 6:47:17 PM8/1/11
to nhusers
Bugs & Features, they are all alike these days... :)

Neo

unread,
Aug 1, 2011, 6:47:26 PM8/1/11
to nhusers
Reply all
Reply to author
Forward
0 new messages