none
LINQ Grouping in Store Procedure RRS feed

  • Question

  • Hi,

    I am using LINQ method to call store procedure now. In the store procedure, i write a query to group the data. So my question is if i call the store procedure in this way, will the output be grouped?

    [Function(Name = "dbo.GetProductionPlan")]
          public ISingleResult<ProdTransaction> GetProductionPlan(string plantIDList, string productIDList, DateTime dateFrom, DateTime dateTo)
          {
              return (ISingleResult<ProdTransaction>)(this.ExecuteMethodCall(this, (MethodInfo)MethodInfo.GetCurrentMethod(), plantIDList, productIDList, dateFrom, dateTo).ReturnValue);
          }

    Sunday, December 1, 2013 12:52 PM

Answers

  • Hello lawrencewong,

    According to your description, if I understand correctly, you have used the keyword ‘Group by’ in the store procedure.

    >> So my question is if i call the store procedure in this way, will the output be grouped?

    Yes, it is and I made an example, it will return the result which is grouped.

    My SP:

    CREATE PROCEDURE [dbo].[ProTest1]
    
           --@OrderID int
    
    AS
    
           SELECT Count(o.OrderID) number,o.OrderCode,o.OrderName from [Order] o
    
            group by o.OrderCode,o.OrderName--where OrderID = @OrderID
    
    RETURN 0
    

    It will create an entity class which has all fields automatically. We can see it in the designer.cs file.

    The result:

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 2, 2013 1:50 AM
    Moderator