开发者

Materialize entities from SqlDataReader

Is it possible to materialize (within the Entity Framework) Entities from a standard SQL Data Reader?

I am writing specific SQL that is passed to th开发者_运维百科e server using EntityConnection.StoreConnection. Thsi returns a standard Data Reader containing rows should be materialized as Entities.

I suppose one workaround is to create a Entity-returning Function Import that can run my arbitrary SQL, but I wonder if there is a neater way?

Regards

Lee


If you want to specify custom SQL for your entity results, you should use either a defining query (see also) (supported by the EF, but not the GUI designer, at least in v1) or a stored proc.

Update: In EF v4, you can use ExecuteStoreQuery<T> and get materialization of arbitrary entities for free.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜