scropio gurl

scropio gurl

  • NA
  • 147
  • 96.9k

Rows return in SP and in LINQ

Jul 27 2016 2:17 AM

I try to call a stored procedure in LINQ.

web method which I try is

  1. [WebMethod]  
  2. public static string search_data(DateTime fromdate, DateTime todate, string region)  
  3. {  
  4.     try  
  5.     {  
  6.         string result = "";  
  7.   
  8.          TrackDataEntities1 td = new TrackDataEntities1();  
  9.   
  10.                 List<griddataresult_Result> dq = new  
  11.                List<griddataresult_Result>();  
  12.                dq = td.griddataresult(fromdate, todate, region).ToList();  
  13.   
  14.         DataTable dt = new DataTable();  
  15.   
  16.         dt.Columns.Add("ID"typeof(int));  
  17.         dt.Columns.Add("Owner"typeof(string));  
  18.   
  19.   
  20.         foreach (var c in dq)  
  21.         {  
  22.             dt.Rows.Add(c.ID, c.owner);  
  23.         }  
  24.   
  25.         result = DataSetToJSON(dt);  
  26.         return result;  
  27.     }  
  28.     catch (Exception)  
  29.     {  
  30.         throw new Exception();  
  31.     }  
  32.  }  
  33.   
  34.  public static string DataSetToJSON(DataTable dt)  
  35.  {  
  36.      Dictionary<stringobject> dict = new Dictionary<stringobject>();  
  37.      object[] arr = new object[dt.Rows.Count + 1];  
  38.   
  39.      for (int i = 0; i <= dt.Rows.Count - 1; i++)  
  40.      {  
  41.          arr[i] = dt.Rows[i].ItemArray;  
  42.      }  
  43.   
  44.      dict.Add("response", arr);  
  45.   
  46.      JavaScriptSerializer json = new JavaScriptSerializer();  
  47.      return json.Serialize(dict);  
  48. }  
 

check image


my sp return return 42 rows but when i run this code show me 577 row in table.. whereas there is not any error


Answers (1)