<分区>
我想从数据库中加载一个元组列表。但是,当像下面这样尝试时。我收到错误消息“LINQ to Entities 中仅支持无参数构造函数和初始值设定项”。
List<Tuple<string, DateTime?>> schdule = new List<Tuple<string, DateTime?>>();
schdule = Entities.ScheduleDates.Where(x => x.Code == cCode).Select(x => new Tuple<string, DateTime?>(x.Key, x.Time)).ToList<Tuple<string, DateTime?>>();
但是,通过使用匿名类型,我不会收到任何错误。
var tempSchedule = Entities.ScheduleDates.Where(x => x.Code == cCode).Select(x => new { x.Key, x.Time }).ToList();
为什么我会遇到上述错误。