views:

99

answers:

1

(See this related question for LINQ-to-SQL)

I'd like to map a class that has a URI member to a string column using NHibernate. How exactly might I accomplish that?

I don't think the solution given to the related question works here - I can't declare a private field and map it, because the mapping needs to reference that field.

+3  A: 

The same solution would work fine; You could define the string property as private so it is not exposed to anyone.

Fluent NHibernate doesn't handle this as easily as standard HBM files, but it can be done a few ways. See the Fluent NHibernate Wiki for instructions.

Alternatively, I think you'd have to define an IUserType class that can load/save the value as a string. Example of doing this with Fluent NHibernate can be found at the end of this blog post.

Chris Shaffer
Updated the question - I'm using Fluent NHibernate. How would such a mapping work? (Code sample if possible).
ripper234
Added links to examples for both options.
Chris Shaffer
Looks interesting, thanks.
ripper234