문제

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.)

도움이 되었습니까?

해결책

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
                      };
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top