I add a feedback through a method (on the Team and User classes) like
this:

public void AddFeedback(WorkerFeedback feedback)
{
  FeedbacksReceived.Add(feedback);
  //Do some calculations here.
}

I thought that simply putting the feedback into the collection should
mean it's recipient is automatically mapped.  But it's not working
that way.  Instead, I have to manually set the feedback's Recipient
AND add it to the collection.

On Nov 17, 1:33 pm, JakeS <[email protected]> wrote:
> I must be missing something small-- I have a "feedback" class that can
> be given to either a user or a team.  The mapping is like this:
>
> [ActiveRecord]
> public class Team : ModelBase<Team>, IFeedbackRecipient
> {
>   [HasMany(typeof(WorkerFeedback), Table = "WorkerFeedback", ColumnKey
> = "RecipientID", Lazy=true)]
>   private IList<WorkerFeedback> FeedbacksReceived{get;set;}
>
> }
>
> [ActiveRecord]
> public class User: ModelBase<User>, IFeedbackRecipient
> {
>   [HasMany(typeof(WorkerFeedback), Table = "WorkerFeedback", ColumnKey
> = "RecipientID", Lazy=true)]
>   private IList<WorkerFeedback> FeedbacksReceived{get;set;}
>
> }
>
> [ActiveRecord]
> public class WorkerFeedback : ModelBase<WorkerFeedback>
> {
>   [Any(typeof(int), MetaType = typeof(string), TypeColumn =
> "RecipientType", IdColumn = "RecipientID", Cascade =
> CascadeEnum.SaveUpdate)]
>   [Any.MetaValue("USER", typeof(User))]
>   [Any.MetaValue("TEAM", typeof(Team))]
>   public IFeedback Recipient
>   {
>     get { return _recipient; }
>     set { _recipient = value; }
>   }
>
> }
>
> If I do a test, create a couple of WorkerFeedback instances and assign
> them to a team, I can see the data added to my WorkerFeedback table.
> But the RecipientType column is null instead of having "TEAM" as I'd
> expect.
>
> Can someone point out my mistake?

--

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


Reply via email to