开发者

InvokeOperation entities become null

This is my method :-

   [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开发者_如何学Python.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;
    }

As you can see i programmatically populate the entities and populate it. When i put breakpoint on return familyEvents, i can see the correct data. However on client side, the TreeMember and RelatedTreeMember value become null. Why is it so? If i do not use [Invoke] and instead use [Query] it works, but i need Invoke in my case.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜