ITypeConvention using multiple columns - how?

22 views
Skip to first unread message

mcintyre321

unread,
Jan 13, 2009, 4:33:37 AM1/13/09
to Fluent NHibernate
I've created a handy class called SerializedTypeConvention<T> which
will serialize a type on an entity into an nvarchar(max) field which
I'll be releasing on my blog soon. The problem is that the serialized
object is serialized as XML and as such isn't searchable. The specific
case I'm having a problem with is with a property

class MyEnitity{
LatLng CurrentLocation {get;set;}
}

where LatLng is

class LatLng{
double Lat {get;set;}
double Lng {get;set;}
}

What do I have to do to get this to be saved to two columns,
CurrentLocation_Lat and CurrentLocation_Lng? Something like
the .TheColumnNameIs(property.Name + "???"); ?

thanks!

James Gregory

unread,
Jan 13, 2009, 4:40:20 AM1/13/09
to fluent-n...@googlegroups.com
I think you need to be looking at a ICompositeUserType from NHibernate, which you should then be able to specify with CustomTypeIs when mapping your CurrentLocation.

mcintyre321

unread,
Jan 13, 2009, 5:37:00 AM1/13/09
to Fluent NHibernate
Cheers James. Will look into it. In fact, I'm kindof hoping this might
be possible eventually

suppose we have a class

class GridSection{
LatLng NorthEast{get;set;}
LatLng SouthWest {get;set;}
}

and our class MyEntity has a CurrentGridSection property

so we end up with columns

dbo.MyEntity.CurrentGridSection_NorthEast_Lat
dbo.MyEntity.CurrentGridSection_NorthEast_Lng
dbo.MyEntity.CurrentGridSection_SouthWest_Lat
dbo.MyEntity.CurrentGridSection_SouthWest_Lng

i.e. it is recursively examining the types when it tries to make the
columns.

On Jan 13, 9:40 am, James Gregory <jagregory....@gmail.com> wrote:
> I think you need to be looking at a ICompositeUserType from NHibernate,
> which you should then be able to specify with CustomTypeIs when mapping your
> CurrentLocation.
>

James Gregory

unread,
Jan 13, 2009, 5:43:24 AM1/13/09
to fluent-n...@googlegroups.com
I can't say either way, I don't have that much experience in implementing composite user types. I don't think it'd be impossible though.
Reply all
Reply to author
Forward
0 new messages