InvokeOperation实体变为null

时间:2011-03-27 10:07:59

标签: silverlight silverlight-4.0 silverlight-3.0 wcf-ria-services

这是我的方法: -

   [Invoke]
    public List<FamilyEvent> GetFamilyEvents(int userId)
    {
        List<FamilyEvent> familyEvents = new List<FamilyEvent>();
        int id = -1; //just to fool ria
        //this is for birthday reminders.
        var qry = ((from member in this.ObjectContext.TreeMembers.Where(m => m.UserId == userId && m.Birthdate == null)
                    select member.TreeMemberId).Except(from item in this.ObjectContext.FamilyEvents where item.ReminderType == 
                                                           FMT.Data.Web.Helpers.Global.FAMILY_EVENTS_REMINDERS.BIRTHDAY_REMINDER 
                                                       select item.TreeMemberId));

        var mainQry = from mainMember in this.ObjectContext.TreeMembers
                      where qry.Contains(mainMember.TreeMemberId)
                      select mainMember;

        foreach (var item in mainQry)
        {
            FamilyEvent familyEvent = new FamilyEvent
            {
                FamilyEventId = id--,
                TreeMemberId = item.TreeMemberId,  
                RelatedTreeMemberId = -1,
                ReminderType = FMT.Data.Web.Helpers.Global.FAMILY_EVENTS_REMINDERS.BIRTHDAY_REMINDER
            };
            familyEvent.TreeMember = item;

            familyEvents.Add(familyEvent);
        }

        //this is for anniversary events
        qry = ((from member in this.ObjectContext.TreeMembers.Where(m => m.UserId == userId && m.RelationId == (short)Relations.Partner)
                select member.TreeMemberId).Except(from item in this.ObjectContext.FamilyEvents where item.ReminderType == FMT.Data.Web.Helpers.Global.FAMILY_EVENTS_REMINDERS.ANNIVERSARY_REMINDER
                                                   select item.TreeMemberId));

        mainQry = from mainMember in this.ObjectContext.TreeMembers.Include("RelatedTreeMember")
                  where qry.Contains(mainMember.TreeMemberId)
                  select mainMember;

        foreach (var item in mainQry)
        {
           FamilyEvent familyEvent = new FamilyEvent
            {
                TreeMemberId = item.TreeMemberId,
                TreeMember = item,

                RelatedTreeMemberId = item.RelatedTreeMemberId,
                ReminderType = FMT.Data.Web.Helpers.Global.FAMILY_EVENTS_REMINDERS.ANNIVERSARY_REMINDER
            };
           familyEvent.RelatedTreeMember = item.RelatedTreeMember;
            familyEvents.Add(familyEvent);


        }

        return familyEvents;
    }

正如您所见,我以编程方式填充实体并填充它们。当我在返回familyEvents上放置断点时,我可以看到正确的数据。但是在客户端,TreeMember和RelatedTreeMember值变为null。为什么会这样?如果我不使用[Invoke]而是使用[Query]它可以工作,但我需要在我的情况下调用。

0 个答案:

没有答案