Custom Types

208 views
Skip to first unread message

Derek Greer

unread,
Aug 31, 2010, 3:42:25 PM8/31/10
to fluent-n...@googlegroups.com
I'm having difficulty mapping a custom type, so looking for some
guidance. Here's my domain:

public class Date
{
DateTime _dateTime;

public Date(int year, int month, int day)
{
_dateTime = new DateTime(year, month, day);
}

public int Year
{
get { return _dateTime.Year; }
}

public int Month
{
get { return _dateTime.Month; }
}

public int Day
{
get { return _dateTime.Day; }
}

/* snip */
}

public class Schedule : EntityBase
{
public Date StartDate { get; set; }

/* snip */
}

I'm trying to get this mapped to an SQL date type.

I've read the following:
http://jagregory.com/writings/fluent-nhibernate-auto-mapping-type-conventions/
http://intellect.dk/post/Implementing-custom-types-in-nHibernate.aspx

The problem I've run into thus far is that the example uses
ITypeConvention which according to
http://wiki.fluentnhibernate.org/Converting_to_new_style_conventions
is now IClassConvention. Can someone provide an example of using this
type to specify the custom type and column name?

Derek Greer

unread,
Aug 31, 2010, 5:22:06 PM8/31/10
to fluent-n...@googlegroups.com
I was able to get this working. The part I was missing was
UserTypeConvention<DateType>.

Derek

Reply all
Reply to author
Forward
0 new messages