none
Linq and Stored Procs (ISingleResult) RRS feed

  • Question

  • Hi all, I read every topic and this and still havent found a solution to my problem. I am using Linq as a DAL and want to call an SP and return the data to my presentation layer or WCF service. This is how I am calling the SP.

     

     

    public List<usp_GetGroupInfoResult> GetGroupInfo(int? groupId)

    {

     

     

    //ISingleResult<usp_GetGroupInfoResult> ro;

     

     

    List<usp_GetGroupInfoResult> mylist = new List<usp_GetGroupInfoResult>();

     

     

    using (SocialDBDataContext db = new SocialDBDataContext())

    {

     

     

    List<usp_GetGroupInfoResult> results = db.usp_GetGroupInfo(groupId).ToList<usp_GetGroupInfoResult>();

     

     

    foreach (usp_GetGroupInfoResult i in results)

    {

    mylist.Add(i);

    }

    }

     

     

    return mylist;

    This is failing. I want to make sure I DO NOT specify the columns in SP or class.

     

    help please


    brian walters
    Wednesday, October 13, 2010 5:19 PM

Answers

  • Hi Brian,

    Welcome to MSDN forums.

    When you mentioned "it is failing", did you get any exception or error ? If so, what's the content of it ? And what do mean by " I want to make sure I DO NOT specify the columns in SP or class.", could you please clarify this ? In addition, I think your code could be simply like this:

    public List<usp_GetGroupInfoResult> GetGroupInfo(int? groupId)
    {
      //ISingleResult<usp_GetGroupInfoResult> ro;
      List<usp_GetGroupInfoResult> mylist = null;
      using (SocialDBDataContext db = new SocialDBDataContext())
      {
        mylist = db.usp_GetGroupInfo(groupId).ToList<usp_GetGroupInfoResult>();
      }
      return mylist;
    }
    
    


    Best regards,

    Alex Liang

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by brianwalters Tuesday, October 19, 2010 6:00 PM
    Thursday, October 14, 2010 6:52 AM
    Moderator

All replies

  • Anyone out there?
    brian walters
    Wednesday, October 13, 2010 9:55 PM
  • Hi Brian,

    Welcome to MSDN forums.

    When you mentioned "it is failing", did you get any exception or error ? If so, what's the content of it ? And what do mean by " I want to make sure I DO NOT specify the columns in SP or class.", could you please clarify this ? In addition, I think your code could be simply like this:

    public List<usp_GetGroupInfoResult> GetGroupInfo(int? groupId)
    {
      //ISingleResult<usp_GetGroupInfoResult> ro;
      List<usp_GetGroupInfoResult> mylist = null;
      using (SocialDBDataContext db = new SocialDBDataContext())
      {
        mylist = db.usp_GetGroupInfo(groupId).ToList<usp_GetGroupInfoResult>();
      }
      return mylist;
    }
    
    


    Best regards,

    Alex Liang

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by brianwalters Tuesday, October 19, 2010 6:00 PM
    Thursday, October 14, 2010 6:52 AM
    Moderator
  • Hi Brian,

    I am writting to follow up the post. Does the above suggestion work ? Or could you please provide more information ? Thanks.

    Please feel free to let me know if you need help.

    Best regards,

    Alex Liang

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, October 19, 2010 9:49 AM
    Moderator