0

I am working on a code template to create POCOs from my Db Schema.

Is there a kind of summary list that defines the MUST-TO-HAVEs in a class so that it can be mapped to Db with NHibernate without any problem.

(As I know, one of the rules is to have your properties virtual so that NHibernate proxies can override)

Thanks!

pencilCake
  • 51,323
  • 85
  • 226
  • 363
  • I'm not using NHibernate directly. Instead I'm using Castle ActiveRecord which is a wrapper around it and works completely declarative. I just can tell you, that ActiveRecord does'nt require any changes to your code to work. – Alexander Schmidt Jul 14 '11 at 06:32

1 Answers1

3

well, besides the virtual properties you must also:

  • have a parameter-less constructor, even if private/protected
  • have a property (or combination of properties) that identify an object (usually the primary key of the table)
  • override int GetHashCode() and bool Equals(object obj) by using the aforementioned object identifier in their body
Jaguar
  • 5,929
  • 34
  • 48