【发布时间】:2011-10-31 09:08:50
【问题描述】:
我有一个 Web 服务,它在我的 json 字符串中返回一个十进制值,但它会将 400.00 到 400 的数字四舍五入,但如果它有 400.50,它会返回 400.50,这就是我想要的我如何返回一个值即 400 到 400.00 的格式
错误
{"Message":"LINQ to Entities 无法识别方法 \u0027System.String ToString(System.String)\u0027 方法,并且此方法无法转换为存储表达式。","代码
产品 = ( 来自 db.Products 中的 p,其中 p.DepartmentId == qDepartment.Id 在 p.Id 上的 db.ProductImages 中加入 i 等于 i.ProductId 进入产品 来自 products.Where(y => y.Dimension == "180X180") 中的 x 选择新产品 { Id = p.Id, 标题 = p.标题, ShortDescription = p.ShortDescription, 品牌 = p.品牌, 型号 = p.Model, 图像 = x.路径, FriendlyUrl = p.FriendlyUrl, SellPrice = p.SellPrice.ToString("N2")/*Error Here changed type to string*/, DiscountPercentage = p.DiscountPercentage, 投票 = p.Votes, TotalRating = p.TotalRating }).ToList();【问题讨论】: