我一直在尝试获取列表中的记录列表,其中列调度>今天(当前日期+时间)
var billPays = from s in db.BillPays.SqlQuery("SELECT * FROM BillPay WHERE " + 1 + " = Active AND " + DateTime.Now + " > ScheduleDate").ToList()
select new BillPayModel
{
//model
};
return View(billPays);
不幸的是,这并没有返回任何东西。有人可以帮忙吗?
答案 0 :(得分:0)
试试这个:
var billPays = from s in db.BillPays.SqlQuery("SELECT * FROM BillPay WHERE '"+ DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")+"' > ScheduleDate").ToList()
select new BillPayModel
{
//model
};
答案 1 :(得分:0)
string myQuery = string.Format("SELECT * FROM BillPay WHERE 1 = Active AND {0:s} > ScheduleDate", DateTime.now);
var billPays = from s in db.BillPays.SqlQuery(myQuery).ToList();
select new BillPayModel
{
//model
};
return View(billPays);