views:

70

answers:

3

We are using ado.net entity framework 4.0 for our database layer and I am a newbie to ado.net entity framework. I have created entity via adding a entity in entity framework. I want to map that entity with stored procedure only not table of the database. Stored procedure will return same column as entity. How it is possible and how i can do that without mapping to table?

+2  A: 

Here is a complete walkthrough http://msdn.microsoft.com/en-us/library/cc716679.aspx

Yury Tarabanko
I just want to bind entity with stored procedure not with database tables. The walk-though you suggested does not say this.
jalpesh
If you want just to retrieve entity via store proc: http://msdn.microsoft.com/en-us/library/cc716672.aspx
Yury Tarabanko
A: 

Its not possible because an ObjectSet is an IQueryable and mapping an ObjectSet to stored procedure would not give u an IQueryable because stored procedures by their very nature cannot be composed. The best you can do is take the content inside the stored procedure and put into a view and map the view to an ObjectSet which is possible.

zeeshanhirani
It is possible with linq-to-sql then why its not possible with Entity framework? I have done that many time with Linq.
jalpesh
What I am saying that I don't want a entity to bind with tables. I want to use this entity as a result of my stored procedures select statement like select productid,productname from product and there will be a prouct class which will have those proeperties. But I don't want to bind product to product tables I just want to bind that with stored procedure.
jalpesh
ok rest assured, it is not supported. There has been internal debates on this issue but i am not sure if this would be supported in near future.
zeeshanhirani
A: 

Then i am not understanding your question. you can map insert,update and delete operations of an entity to stored procedure. You can expose stored procedures as methods on the object context. In .net 4.0, an ObjectSet can only be bound to a table or a view.

zeeshanhirani