开发者

Linq grouping .include("Table") returning null on Table

I have a linq query that is grouping by answers by QuestionGroup.

I need to have the table AssessmentQuestionsReference load so that i can bind to it in my WPF app.

   var groupedAnswers = from a in App.ents.AssessmentAnswers.Include("AssessmentQuestions")
                        where a.Organisations.Organisa开发者_Python百科tionID == App.selectedOrganisation.OrganisationID
                        group a by a.AssessmentQuestions.AssessmentQuestionGroups.QuestionGroup into g
                        select new { Group = g.Key, Answer = g };

When i drill down into g, AssessmentQuestions is "null". I am not sure why as i thought it should have loaded it even without the include as i am going through that table to get the question groups.

Any ideas?


Have you tried including AssessmentQuestions.AssessmentQuestionGroups?

Your .Include("AssessmentQuestions") will pull in a.AssessmentQuestions, but not a.AssessmentQuestions.AssessmentQuestionGroups.


I add for check alike string and include with group worked unexpected. This is strange but work

var yy = (from r in context.RateSet.Include(x => x.Currency).Include(y => y.Currency1)
                      select r).ToList();
var xx = (from r in context.RateSet.Include(x => x.Currency).Include(y => y.Currency1)
                  orderby r.DateRate, r.Currency.NameCurrency
                  group r by new { r.IdFromCurrency, r.IdToCurrency} into gp
                  select gp.FirstOrDefault()).ToList();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜