I've a query like this one
struct MyStruct
{
public string name;
public double amount;
}
var a =
from p in Products
select new MyStruct
{
name = p.Name,
amount = p.Amount
};
When I execute the query I get the following exception:
System.NotSupportedException {"Only parameterless constructors and initializers are supported in LINQ to Entities."}
but if I change the type of MyStruct to class then it works as expected.
Why it works with class and fail with struct?