According to this blog post it is possible to change readonly fields using reflection. Futhermore, there seem to be no special trickery involved. It seems reasonable then to expect that NHibernate's code that deals with non-readonly fields would be able to handle it just fine.
http://blogs.microsoft.co.il/blogs/tamir/archive/2007/07/22/Hack-read-only-properties-and-fields-using-reflection.aspx I suppose you will have to actually test it to verify but that should not take long. /Oskar 2009/9/4 Billy Stack <[email protected]>: > > Encapsulation is a concept that I am familiar with, however for the > simple entity type described, > needing to have private properties is totally unnecessary IMO. > > If I need to change my type definition to work for NH but still be > immutable I can use the following approach: > > public class Entity > { > private readonly int m_Property1; > private readonly int m_Property2; > > public int Property1 { get { return this.m_Property1; } } > > public int Property2 { get { return this.m_Property2; } } > > public Entity(int p1, int p2) > { > this.m_Property1 = p1; > this.m_Property2 = p2; > } > } > > But just to be clear, NHibernate cannot work with with entity types > as defined previously? > On Thu, Sep 3, 2009 at 9:27 PM, Paco Wensveen<[email protected]> wrote: >> >> The lack of incapsulation. You can not inherit this class and change >> anything. This also means it cannot be proxied by NHibernate. >> >> Protect your private parts! > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" 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/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
