When you specify ReportID in the BelongsTo attribute, you're actually 
specifying the ReportID *column*, not property.  When you map two properties to 
the same column NH needs to be told which one is the authority.  This is done 
with the Insert = false and Update = false attributes.  If you want to avoid 
this you can do something like this:

[BelongsTo("ReportID")]
public virtual Report Report { get; set; }

public int ReportID { get { return Report.ReportID; } }

I would recommend doing away with the ReportID property altogether, though, 
since it is so easy to access that value through the Report property.

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of khaavren of 
castlerock
Sent: Wednesday, April 01, 2009 7:17 PM
To: Castle Project Users
Subject: Re: on [BelongsTo] association column


But what if I want both to be insertable/updateable?  It seems to me
that ReportID would "just work" without a [Property] attribute.  That
is, if I specify ReportID as the BelongsTo, why wouldn't the
ReportID .net property do what would be expected?

On Apr 1, 12:35 pm, Tyler Burd <[email protected]> wrote:
> You can mark one as Insert=false and Update=false like this:
>
> [Property(Insert = false, Update = false)]
> public int ReportID { get; set; }
>
> That tells NHibernate/ActiveRecord to skip over that property at insert or 
> update time.  It will still load the value when the entity is loaded from the 
> db.
>
> Does that help?
> -tyler
>
> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of khaavren of 
> castlerock
> Sent: Wednesday, April 01, 2009 8:53 AM
> To: Castle Project Users
> Subject: [Property] on [BelongsTo] association column
>
> Hello,
>
> I'm wondering if there is something I need to do to get the following
> to work without creating undesirable results:
>
>         [BelongsTo("ReportID")]
>         public virtual Report Report { get; set; }
>
>         [Property]
>         public int ReportID { get; set; }
>
> Thanks


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" 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/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to