tags:

views:

58

answers:

1

Hi,

In my hbm files I did this:

 <property name="Title" column="title" type="string" length="100" not-null="true"></property>

I am assuming this will provide for faster data access because it is providing more information i.e. length.

Does fluent provide this behavior?

+2  A: 

Yes, Fluent NHibernate lets you do the equivalent mapping

  • To specify the length of a string, use the WithLength method.
  • The column name can be specified with the ColumnName method.
  • To make a property not nullable, use the negation property "Not" followed by the method Nullable().
  • You don't need to specify the type of the property since that is inferred by Fluent NHibernate.
  • If you want to specify the data type used in the database, use the CustomSqlTypeIs method.

The Fluent NHibernate mapping would look something like this:

    Map(x = x.Title)
      .ColumnName("title")
      .WithLengthOf(100) 
      .Not.Nullable();
Erik Öjebo