我是Linq的新手,下面的查詢不斷返回「無法識別System.DateTime」錯誤。我試過解析和轉換,但都不起作用。這是我的查詢:LINQ to Entities無法識別方法'System.DateTime Parse(System.String)'方法
mrcEntities context = GetContext();
var query = from c in context.tblClients
where (c.FirstName != null || c.LastName != null)
&& c.EligibilityDate >= DateTime.Parse("10/01/2011")
&& c.EligibilityDate <= DateTime.Parse("04/30/2012")
orderby c.ClientID
select new
{
ClientID = c.ClientID,
FirstName = c.FirstName,
LastName = c.LastName,
MiddleName = c.MidName,
SSN = c.SSN,
DOB = c.DOB,
Sex = c.Gender,
Ethnic = c.EthnicCode
};
clientRowCnt = query.Count();
任何幫助,將不勝感激。
如果DateTime.Parse依賴於「from c」會怎麼樣?例如, DateTime.Parse(c.date)? –
對不起,你能詳細說明一下嗎? 「不認識方法」會不會發生? –
是的,謝謝你! –