I try to call storerprocedure in LINQ but this show error
i try this sp
- ALTER procedure [dbo].[grid_data]
- @region varchar(50),
- @fromdate datetime,
- @todate datetime
- as
- Select tblRV.ID as ID, tblRV.Owner, tblRV.Regno,
- (Select Count(*) as total from tblvv WHERE MID = tblRV.ID and Name <> '')
- as total,tblRV.MA, tblRV.MS
- from tblReg inner join tblRV On tblReg.RID = tblRV.RID
- WHERE tblReg.StartDate >= @fromdate AND tblReg.EndDate <= @todate
- and tblReg.Region = @region
- order by tblRV.Owner
and code
- [WebMethod]
- public static string search_data(DateTime fromdate, DateTime todate, string region)
- {
- try
- {
- string result = "";
- TrackDataEntities1 ts = new TrackDataEntities1();
- var dq = ts.griddata(fromdate, todate, region);
- DataTable dt = new DataTable();
-
- dt.Columns.Add("ID", typeof(int));
- dt.Columns.Add("Owner", typeof(string));
- dt.Columns.Add("RegNo", typeof(string));
- dt.Columns.Add("total", typeof(string));
- dt.Columns.Add("MA", typeof(string));
- dt.Columns.Add("MS", typeof(string));
- foreach (var c in dq)
- {
- dt.Rows.Add(c.ID, c.owner, c.RegNo, c.total, c.MA, c.MS);
- }
-
- result = DataSetToJSON(dt);
-
- return result;
- }
- catch (Exception)
- {
- throw new Exception();
-
-
- }
-
- }
-
- public static string DataSetToJSON(DataTable dt)
- {
-
- Dictionary<string, object> dict = new Dictionary<string, object>();
-
- object[] arr = new object[dt.Rows.Count + 1];
-
- for (int i = 0; i <= dt.Rows.Count - 1; i++)
- {
- arr[i] = dt.Rows[i].ItemArray;
- }
-
- dict.Add("response", arr);
-
- JavaScriptSerializer json = new JavaScriptSerializer();
- return json.Serialize(dict);
-
- }
but this show error on this line
foreach (var c in dq)
foreach statement cannot operate on variables of type 'int' because 'int' does not contain a public definition for 'GetEnumerator'