Protected setters map just fine without any special naming conventions
or mapping.

On Apr 27, 2:20 am, MSD <[email protected]> wrote:
> Can we map a property that has a protected (or even private) setter.
> Do we have to change the naming strategy and have a separate member
> for the property? In the documentation I read: "Properties need not be
> declared public - NHibernate can persist a property with an internal,
> protected, protected internal or private visibility." so what exactly
> does that mean?
>
> Here is an example class:
>
> public class Candidate
>     {
>         virtual public string Number { get; set; }
>         virtual public DateTime AddedOn { get; protected set; }
>         virtual public Template Template { get; set; }
>         virtual public string ZoneName { get; set; }
>         virtual public DateTime LastActivity { get; set; }
>
>         protected Candidate()
>         {
>
>         }
>         public Candidate
>             (string number, TemplateType candidateFor, DateTime
> addedOn, string zoneName)
>         {
>             this.Number = number;
>             this.AddedOn = addedOn;
>             this.ZoneName = zoneName;
>         }
>         public override bool Equals(object obj)
>         {
>             Candidate that = obj as Candidate;
>             if (that == null) return false;
>             return this.Number.Equals(that.Number);
>         }
>         public override int GetHashCode()
>         {
>             return this.Number.GetHashCode();
>         }
>     }
>
> and here is an example mapping:
>
> <?xml version="1.0" encoding="utf-8" ?>
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
> assembly="MNP_Contracts" namespace="MNP_Contracts">
>     <class name="Candidate" table="Candidates" dynamic-update="false"
> lazy="false">
>         <id name="Number" column="Number">
>             <generator class="assigned" />
>         </id>
>         <property name="AddedOn" column="AddedOn" />
>         <property name="ZoneName" column="ZoneName" />
>         <property name="LastActivity" column="LastActivity" />
>         <many-to-one name="Template" column="TemplateID" />
>     </class>
> </hibernate-mapping>
>
> the AddedOn property is not being set when NHibernate hydrates the
> object.
>
> --
> 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 
> athttp://groups.google.com/group/nhusers?hl=en.

-- 
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.

Reply via email to