Rather than mapping the two columns as individual properties, what you're probably better off doing is creating a custom IUserType implementation to handle the mapping from the two columns into one one date property (and vice-versa). See section 5.2.3: Custom value Types in the NHibernate Documentation. http://nhforge.org/doc/nh/en/mapping.html#mapping-types-custom
Then, in your mapping (assuming you're doing fluent mapping, not auto mapping), you'd add a call to .CustomType(typeof(DateTimeInTwoColumnsUserType)) for your datetime property. Here's an example: http://elegantcode.com/2009/11/01/state-pattern-enumeration-class-and-fluent-nhibernate-oh-my/ Speaking from experience, custom IUserTypes are not that difficult, and really are your best friend when dealing with a legacy schema. -- Will Green On Aug 26, 11:50 pm, Klaus Lüdenscheidt <[email protected]> wrote: > i'm working with a legacy database which stores month and year of a date in > two string columns. LINQ to NHibernate doesn't support > type conversion inside a query and strings can't be compared with <= or >=. > So i want to define a transient property in my entity > class wich returns a DateTime from the two string columns. Nevertheless how i > define it (virtual, non virtual) i get a > ConfigurationException from FluentNHibernate. When i defne a method which > returns the date LINQ To NHibernate throws an exception. > > Is there any way to tell FluentNhibernate not to map a property to a database > column? > > Regards > Klaus -- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.
