Sandeep Kumar

Sandeep Kumar

  • 1k
  • 683
  • 60.1k

how to get data from stored procedure in web api method

Jul 6 2022 5:01 AM

i have a stored procedure,from sp i want to get data in Var  OverAllsecures varriable.

how to use sp in my in web api method.

  async Task<DashboardData> IDashboardManager.GetDashBoardReport(int jobId)
        {
          
            var OverAllsecures =  //Here i want to fetch data from stored procedure in this  variable

            var ApprovalEngDeliverable = _dbContext.Deliverable.Where(k => k.DeliverableTypeId == 1 && k.JobId == jobId).ToList();
            var InfoEngDeliverable = _dbContext.Deliverable.Where(k => k.DeliverableTypeId == 2 && k.JobId == jobId).ToList();
            var totalEngDeliverable = ApprovalEngDeliverable.Count + InfoEngDeliverable.Count;       
            return await Task.Run(() =>
            {
                return new DashboardData()
                {
                    TotalEngDeliverableCount = (int)totalEngDeliverable,
                    TotalApprovalEngDeliverableCount = (int)ApprovalEngDeliverable.Count,
                    TotalInfoEngDeliverableCount = (int)InfoEngDeliverable.Count,

           
                    OverallScurve = //Output data i.e OverAllsecures  from sp will be assigned

                };
            });

----------------This my Class----------------

 public class DashboardData
    {
        //Eng Deliverable
        public int TotalEngDeliverableCount { get; set; }
        public int TotalApprovalEngDeliverableCount { get; set; }
        public int TotalInfoEngDeliverableCount { get; set; }
     

        public OverAllsecure OverallScurve { get; set; }
    
    }

    public class OverAllsecure
    {

        public List<int> target { get; set; }

        public List<int> acheived { get; set; }
        public List<string> Mnth_Yr { get; set; }

    }

Kindly helo as soon as possible


Answers (2)