linq里这日期怎么处理?
var strSQL1 = from x in edm.VDetailSet
where DATEADD(month, CAST(x.usefullife AS int), x.Update) >= GETDATE()select x
DataList1.DataSource = strSQL1;
DataList1.DataBind();
怎么把sql里的DATEADD(month, CAST(x.usefullife AS int), x.Update) >= GETDATE()用到linq里???
------解决方案-------------------- lINQ to sql
var strSQL1 = from x in edm.VDetailSet
where SqlFunctions.DateAdd(month, CAST(x.usefullife AS int), x.Update) >= GETDATE()
select x;
DataList1.DataSource = strSQL1;
DataList1.DataBind();
LINQ to ef
var strSQL1 = from x in edm.VDetailSet
where SqlMethods.DateDiffMonth(month, CAST(x.usefullife AS int), x.Update) >= GETDATE()
select x;
------解决方案-------------------- 引用: 用的是vs2008
不好意思写反了,更正一下
你如果是LINQ to ef
var strSQL1 = from x in edm.VDetailSet
where SqlFunctions.DateAdd(month, CAST(x.usefullife AS int), x.Update) >= GETDATE()
select x;
DataList1.DataSource = strSQL1;
DataList1.DataBind();
你如果是lINQ to sql
var strSQL1 = from x in edm.VDetailSet
where SqlMethods.DateDiffMonth(month, CAST(x.usefullife AS int), x.Update) >= GETDATE()
select x;
------解决方案--------------------