linq查询问题,
var cardmanages = from c in dc.cardmanage
//from r in dc.Review
//where c.ID == r.card_id
//let a = c.card_start.CompareTo(c.card_end)
//let a=c.review_id
let a = long.Parse(c.card_end)
let b = long.Parse(c.card_start)
let ab = a - b
where c.card_name == CardName
//where DateTime.Parse(startDate)>=DateTime.Parse(c.card_date)
select new Class1
{
name = c.card_name,
Inv = ab,
card_id = c.ID
//time="aaa"
};
return cardmanages.ToList();
card_end,card_start均为字符型,要求输出card_end-card_start的结果,显示如下错误:
无法将表达式“Parse(<>h__TransparentIdentifier2.c.card_start)”转换为 SQL 并且无法将它视为局部表达式。
这是什么原因,大家帮忙给看看
------解决方案--------------------
变换long.Parse方法为Convert.ToInt64方法即可
代码参考
C# code
from item in Authors
let a=Convert.ToInt64(item.Zip)
let b=Convert.ToInt64(item.Zip)
let c=a-b
select new
{
id=item.Au_id,
c
}