Thanks again Greg On Saturday, September 26, 2015 at 2:08:23 PM UTC+1, Greg Young wrote: > > Readonly constraints are not maintained by the CLR. You can still > write to it via reflections but this would require reverse engineering > their namings. I would probably avoid this. > > In practice I would still use the setter. > > On Sat, Sep 26, 2015 at 2:06 PM, sturdytree <[email protected] > <javascript:>> wrote: > > Thanks Greg > > > > So I assume NHIbernate will not be able to write to the backing field by > > reflection as it is read only and therefore we must use public string > Name > > {get; private set;} for NHibernate mapping? > > > > > > On Saturday, September 26, 2015 at 1:23:08 PM UTC+1, Greg Young wrote: > >> > >> public string Name {get;} > >> > >> is not the same as > >> > >> public string Name {get; private set;} > >> > >> The new readonly auto properties emit a readonly backing field and > >> initialization to it. They do not emit a private setter the way {get; > >> private set;} does. > >> > >> Cheers, > >> > >> Greg > >> > >> On Sat, Sep 26, 2015 at 1:17 PM, sturdytree <[email protected]> > >> wrote: > >> > In C# 6.0 we can now write: > >> > > >> > public string Name {get;} > >> > > >> > instead of > >> > > >> > public string Name {get;private set;} > >> > > >> > or using a private backing field. > >> > > >> > Whereas the mapping worked for the old code, the new code now gives a > >> > 'could > >> > not find a setter' exception. > >> > > >> > Is there a way to get NHibernate to work with getter only auto > >> > properties? > >> > > >> > -- > >> > You received this message because you are subscribed to the Google > >> > Groups > >> > "nhusers" group. > >> > To unsubscribe from this group and stop receiving emails from it, > send > >> > an > >> > email to [email protected]. > >> > To post to this group, send email to [email protected]. > >> > Visit this group at http://groups.google.com/group/nhusers. > >> > For more options, visit https://groups.google.com/d/optout. > >> > >> > >> > >> -- > >> Studying for the Turing test > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "nhusers" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to [email protected] <javascript:>. > > To post to this group, send email to [email protected] > <javascript:>. > > Visit this group at http://groups.google.com/group/nhusers. > > For more options, visit https://groups.google.com/d/optout. > > > > -- > Studying for the Turing test >
-- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/d/optout.
