存储过程的使用:
DateTime todayTime = DateTime.Now.AddHours(8);
DateTime yesterdayTime = todayTime.AddDays(-1);
SqlParameter[] parameters1 =
{
new SqlParameter{ ParameterName = "@todayTime",Value = todayTime},
new SqlParameter{ ParameterName = "@yesterdayTime",Value = yesterdayTime},
};
var list = db.Database.SqlQuery<SummarySQLDataModels>("EXEC proc_GetSQLDataByDay @todayTime,@yesterdayTime", parameters1).ToList();
json = Newtonsoft.Json.JsonConvert.SerializeObject(list.ToList());
Model 类型
public class SummarySQLDataModels
{
public string Id{get;set;}
public string UserName{get;set;}
public string Password{get;set;}
}