这里是我的LINQ查询:从LINQ查询转换小数货币
GridView.DataSource = from it in DataContext.Items
where it.ThingId == thing.ThingId
select new
{
it.Something,
it.SomethingElse,
it.AnotherSomething,
Currency = String.Format("{0:C}", it.Decimal.ToString()),
//^--This is the line that needs to be converted to currency, this doesn't work--^
};
的it.Decimal
在形式12345.00
返回一个小数,我需要在GridView显示时将其转换成$12,345.00
。我现在有什么不行,因为LINQ查询不会识别String.Format
函数。有任何想法吗?
当我去databind,我得到这个错误'LINQ to Entities不能识别方法System.String Format(System.String,System.Object)'方法,并且这个方法不能被转换成存储表达式.' –
然后使用第二种形式。 –
@Jordan Foreman,看我更新的回答 –