I continue to work with a template in which I want to select rows from an entity collection (EF4) and use the data to create new rows in another entity collection.
The only way I found this is to follow these steps:
var newEntities = (from e in myentities where ex == y select new { Prop1 = e.Prop1, Prop2 = e.Prop2+e.Prop3, Prop3 = DateTime.Now, Prop4 = "Hardcodedstring"} ) .AsEnumerable() .Select(n=>new OtherEntity{ Prop1 = n.Prop1, Prop2 = n.Prop2, Prop3 = n.Prop3, Prop4 = n.Prop4} ); //insert into database and save
If I try to create a new OtherEntity option in select, I get an EF exception.
Is this the only way? Does all this make it very cumbersome and seem like a complete loss of keystrokes?
source share