I am using EF. This is my LINQ request.
public List<Tuple<int, string>> GetList() { return (from c in DALContext.MST select new Tuple<int, string>(c.CD, c.NAME)).ToList(); }
When I call GetList (), it throws an exception: in LINQ to Entities, only parameterless constructors and initializers are supported
Instead, when I rewrite this query:
List<Tuple<int, string>> lst = new List<Tuple<int, string>>(); var query= (from c in DALContext.MST select new{c.CD, c.NAME}); foreach (var item in query) { lst.Add(new Tuple<int,string>(item.CD,item.NAME)); } return lst;
It just works great. What happened to my first request ???
asp.net-mvc linq-to-entities
Tuscan
source share