【发布时间】:2011-09-25 12:39:07
【问题描述】:
这是我的 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 的形式返回一个小数,当显示在网格视图中时,我需要将其转换为$12,345.00。我现在所拥有的不起作用,因为 LINQ 查询无法识别 String.Format 函数。有什么想法吗?
【问题讨论】: