I’m using EF, so my Child collections are of type EntityCollection < T >. If property “Children” is EntityCollection < T > How do I convert the query result IEnumerable < T > to EntityCollection < T >?
Thanks
var list = element.Elements(ns + "Parent")
.Select(parsedXml =>
Children = parsedXml.Elements(ns + "Child")
.Select(child => new Child {
Id = Convert.ToInt32(child.Attribute("id").Value)
})
});
Since you are already using LINQ you can do this with the same model by creating an extension method:
Then use this in your original LINQ statement by adding
.ToEntityCollection()to the end.