views:

355

answers:

1

In the context of Entity Framework 4, the default behavior when adding a function import is to call it via ExecuteFunction<T>(), where T must apparently implement some property change notification stuff. (In my case it's generating a complex type derived from ComplexObject.)

I don't need or want any change notifications, and I'm required to send POCOs up the line after these sproc calls.

Is there a way to get a POCO directly from an EF sproc call? If not, does anyone have any recommendations on turning my sproc result into a POCO?

(I've played briefly with the POCO Template, but it doesn't seem to support stored procedures in any way.)

+2  A: 

ExecuteFunction<T> returns an ObjectResult<T>, which implements IEnumerable<T>, so you can project the T onto anything via LINQ. E.g.:

IEnumerable<MyPoco> = from f in Context.MyFunction()
                      select new MyPoco
                      {
                          A = f.A,
                          B = f.B
                      };
Craig Stuntz
That's just wonderful compared to the alternatives I was considering - thank you!
ladenedge