Linq to sql中有將string轉換成datetime的方法嗎?
sql: select datediff(dd,convert(datetime,'2010/11/2'),GETDATE())
換成Linq:
var pcrDetail = from p in db.PcrDetail
where new string[] { "Open", "Reject" }.Contains(p.Task_Status) && !p.Project_No.ToLower().StartsWith("tmp")
&& SqlMethods.DateDiffDay(SqlMethods.DateDiffDay( DateTime.Now) >= minDay && SqlMethods.DateDiffDay(DateTime.Parse(p.Task_DueDate), DateTime.Now) <= maxDay
select p;
int j = 0;
報錯:說Linq to sql不支持在裏面直接寫DateTime.Parse(p.Task_DueDate).
請問這裡應該怎樣寫(不在外面再定義時間格式的參數)?