how to execute stored procedure using Entity and .edmx file to query database tables RRS feed

  • Question

  • I have already imported the store procedures and functions.

    I can see the stored procs and functions in the model browser

    Let's say the model entity is myEnttity and a desired sp is getValuation

    however I failed to see anything like what I am looking for.

    myEntity context = new myEntity();

    var values = from p in context.getValuation   /// oops nothing like context.getValuation.

    do I have to import function for each sp and stored functions along with any entity defition for result set?

    what to do with stored proc the returns only subset of an entity(some rows of table) or nothing like any entity (table)

    how do I map out parameters of stored procedure?

    • Edited by fs - ab Wednesday, April 4, 2012 8:42 AM
    Wednesday, April 4, 2012 7:58 AM


All replies

  • Please refer to the steps below,

    1. Right click at the space of your .edmx file.

    2. Add -> Function Import.

    3. Named your function or stored procedure, specify the return type, if the return type is not a entity type, select "Create New Complex Type".

    4. Click OK.

    Now, you can invoke the function or sp by context.

    I hope this can help.

    Fighting like Allen Iverson. Neve give up!

    Thursday, April 5, 2012 5:51 AM
  • thx, hero

    are you talking about Ef 4?  I'm still using EF 3.5 with vs 2008 standar along with .net3.5

    I failed to find the choice of complex type

    I saw no value returned, scalar, and entity

    Thursday, April 5, 2012 7:32 AM
    • Marked as answer by Allen_MSDN Monday, April 9, 2012 2:19 AM
    Thursday, April 5, 2012 7:52 AM
  • Hi fs - ab,

    Welcome to MSDN Forum.

    In EF3.5, you have to modify the SSDL file manually to map your custom entity, @Hero's link is a good tutorail to lead you to do that. Please refer to the link.

    Best Regards

    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Friday, April 6, 2012 5:21 AM