小编Bar*_*art的帖子

Linq使用GroupBy时,Include无效

包括matchparticipants不工作.我在调试时总是说Null.但是,当我将GroupBy置于评论中时,它可以正常工作.我使用实体框架4.3.1与代码优先.

实体:

public class Match
    {
        [ScaffoldColumn(false)]
        public int MatchId { get; set; }

        [Required(ErrorMessage = "Matchtype is a required field")]
        public int Scheme { get; set; }

        [Required]
        [DefaultValue(false)]
        public bool Finished { get; set; }

        public int Round { get; set; }


        // Relations
        [Required]
        public Category Category { get; set; }

        public Official Official { get; set; }

        public Slot Slot { get; set; }

        public ICollection<MatchParticipant> MatchParticipants { get; set; }
    }

 public class MatchParticipant
    { …
Run Code Online (Sandbox Code Playgroud)

linq-to-entities ef-code-first entity-framework-4.3

26
推荐指数
2
解决办法
1万
查看次数