I have a stored proc in Entity Framework 5, returning multiple result sets of entities.
Attaching each entity to the context is very slow.
Is there a better / faster / easier way to do this?
using (var context = new MyEntities())
{
var resultSet1 = context.ExecMyStoredProc();
foreach (var a in resultSet1) context.ASet.Attach(a);
var resultSet2 = resultSet1.GetNextResult<B>();
foreach (var b in resultSet2) context.BSet.Attach(b);
var resultSet3 = resultSet2.GetNextResult<C>();
foreach (var c in resultSet3) context.CSet.Attach(c);
.
.
}
Do you need to attach the results at all? As far as I understand entities returned from stored procedures are automatically being tracked as AppendOnly.