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?
views:
70answers:
3
+2
A:
Here is a complete walkthrough http://msdn.microsoft.com/en-us/library/cc716679.aspx
Yury Tarabanko
2010-07-13 11:49:25
I just want to bind entity with stored procedure not with database tables. The walk-though you suggested does not say this.
jalpesh
2010-07-14 06:00:35
If you want just to retrieve entity via store proc: http://msdn.microsoft.com/en-us/library/cc716672.aspx
Yury Tarabanko
2010-07-14 06:13:41
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
2010-07-14 22:34:04
It is possible with linq-to-sql then why its not possible with Entity framework? I have done that many time with Linq.
jalpesh
2010-07-15 09:22:18
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
2010-07-19 10:27:07
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
2010-07-19 13:53:20
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
2010-07-15 14:51:29