locked
Implementing a stored procedure returning the different result RRS feed

  • Question

  • Hello,

    I'm thinking of writing a generic stored procedure. It'll accept one parameter, and the result type is determined by its parameter.

    For example, sometimes the stored procedure returns a string and an integer, but it can return two strings as well.

    I think that it's impossible to use a stored procedure having the same inputs, but the different results.

    However, I want to ask this question just to be sure. is it possible to use this kind of stored procedures in Entity Framework?

    Thanks,

    Sung Am

    Thursday, January 3, 2013 3:56 PM

Answers

  • I determined to use one stored procedure, but many service operations having the different return types.


    Thanks,

    Sung Am

    • Marked as answer by byHesed Thursday, January 3, 2013 4:34 PM
    Thursday, January 3, 2013 4:34 PM

All replies

  • I determined to use one stored procedure, but many service operations having the different return types.


    Thanks,

    Sung Am

    • Marked as answer by byHesed Thursday, January 3, 2013 4:34 PM
    Thursday, January 3, 2013 4:34 PM
  • If it is just integer to string and string to integer conversion then you can simply use CAST operation. This makes sure that you every time return a string value to the WCF service.

    If it is involve different types for complexity imagine you need to return rows from 2 different tables, then you would have to configure your WCF to accept multiple result sets.

    Please refer the following article.

    http://msdn.microsoft.com/en-us/library/bb425822.aspx#linqtosql_topic31

    And hop into the section “Stored Procedures Invocation” with multiple result sets.

    Friday, January 4, 2013 8:36 PM
  • Thanks Hasitha for your comment.

    I'll remember your reply and refer to the link If I need multiple result sets.

    Have a very good day.

    Sung Am

    Tuesday, January 15, 2013 10:41 AM