using stored procedures in ado .net Entity Data model as functions RRS feed

  • Question

  • Hi,

    I m trying to build a web site which will use ADO .NET ENTITY DATA MODEL (.net framework 3.5)for database interactions. I have added some stored procedures to the entity model. But I can only access those stored procedures which returns entity set. All other SPs which return "scalar" or "none" are not accessible in the code.

     This procedure was simple and straight forward in LINQ to SQL. Where we could access all the stored procedures (irrespective of return type) directly in our code behind as methods.

    Can we extend the entity classes to expose those SPs to the code behind. Or is there any other solution?


    Please help !!

    Monday, April 6, 2009 10:57 AM


All replies

  • You *can* map the CUD behaviors of entity types to stored procedures: How to: Map Modification Functions to Stored Procedures, Walkthrough: Mapping an Entity to Stored Procedures.

    Otherwise, if you are simply looking to expose a stored procedure that returns "scalar" or "none" on the ObjectContext, you have to write that code yourself. This forum post explains how. Doing code generation for these types of stored procedures has been requested often - we hope to address this in the next release.

    Hope that helps.

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Monday, April 6, 2009 3:16 PM
  • Thanks Brian,

    Your suggestion helped me a lot. I have generated some code to expose the stored procedures on the Object Context. And its working fine.

    I hope the next release will have automatic code generation feature. So that it will easier to use.

    Tuesday, April 7, 2009 5:24 AM