I'm attempting to load a collection of KeyValuePairs from the following EF/Linq query:
return (from o in context.myTable select new KeyValuePair<int, string>(o.columnA, o.columnB)).ToList();
My issue is that the error stems from this.
"Only parameterless constructors and initializers are supported in LINQ to Entities."
Is there a simple workaround for this? Instead of using KeyValuePair, I could make an own class, but that seems like reinventing the wheel.
Due to the fact that LINQ to Entities does not
you should use LINQ to Object to convert to
return context.myTable .AsEnumerable() .Select(new KeyValuePair<int, string>(o.columnA, o.columnB)) .ToList();