“A lambda expression with a statement body cannot be converted to an expression tree”

In using the EntityFramework, I get the error “A lambda expression with a statement body cannot be converted to an expression tree” when trying to compile the following code: Obj[] myArray = objects.Select(o => { var someLocalVar = o.someVar; return new Obj() { Var1 = someLocalVar, Var2 = o.var2 }; }).ToArray(); I don’t know what … Read more

Check if two lists are equal

I have a class as follows: public class Tag { public Int32 Id { get; set; } public String Name { get; set; } } And I have two lists of tag: List<Tag> tags1; List<Tag> tags2; I used LINQ’s select to get the Ids of each tags list. And then: List<Int32> ids1 = new List<Int32> … Read more