I have the following stored procedure:
/****** Object: StoredProcedure [dbo].[OpsToolStats] Script Date: 09/05/2023
09:21:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author, , Name>
-- Create Date: <Create Date, , >
-- Description: <Description, , >
-- =============================================
ALTER PROCEDURE [dbo].[OpsToolStats]
(
-- Add the parameters for the stored procedure here
@startDate datetime,
@endDate datetime
)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON
SELECT count([EndCustomerOrderId]) AS NewOrdersNeedsLabels
FROM [dbo].[EndCustomerOrders]
where ([StatusId] = 0 or [StatusId] = 1000) and CreatedAt >= @startDate and [CreatedAt]
<= @endDate
SELECT count([EndCustomerOrderId]) AS APIErrorCeatingLabels
FROM [dbo].[EndCustomerOrders]
where [StatusId] = 1100 and CreatedAt >= @startDate and [CreatedAt] <= @endDate
SELECT count([EndCustomerOrderId]) AS ScheduleCollection
FROM [dbo].[EndCustomerOrders]
where ([StatusId] = 1300 or [StatusId] = 1500 or [StatusId] = 1700) and CreatedAt >=
@startDate and [CreatedAt] <= @endDate
END
In SQL Enterprise manager the results visually look like this:
I am trying to work out how to call this SP and get the results of the individual select statements:
I have the following code:
var command = _dbLive.Database.GetDbConnection().CreateCommand();
command.CommandText = "OpsToolStats";
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("@startDate", "2023-05-01"));
command.Parameters.Add(new SqlParameter("@endDate", "2023-05-31"));
_dbLive.Database.OpenConnection();
using var result = command.ExecuteReader();
var dataTable = new DataTable();
dataTable.Load(result);
But I only get 1 column and 1 row in the datatable... for the "NewOrdersNeedsLabels"..
Can anyone suggest how to get all the values please?