我使用的是Oracle Client 11.2.0.3和11g Oracle数据库,在将数字列数据转换为字符串时遇到了问题。
var items = new List<string>();
items = (from x in db.Table1
select x.ColA).ToList()); // ColA is NUMBER(9)如果我使用Convert.ToString(x.ColA),我会得到LINQ to Entities does not recognize the method System.String ToString(Int32) method, and this method cannot be translated into a store expression
如果我使用x.ColA.ToString(),我会得到LINQ to Entities does not recognize the method System.String ToString() method, and this method cannot be translated into a store expression.
如果我使用System.Data.Objects.SqlClient.SqlFunctions.StringConvert((double)x.RESERVATION_ID),我会得到The specified method System.String StringConvert(System.Nullable1[System.Double]) on the type System.Data.Objects.SqlClient.SqlFunctions cannot be translated into a LINQ to Entities store expression.
发布于 2012-08-21 05:37:21
items = (from x in db.Table1
select x.ColA).ToList().Select(x => x.ToString()).toList())发布于 2012-08-21 05:45:27
var items = (from x in db.Table1 select x.ColA).ToList()
.ConvertAll(s => s.ToString());https://stackoverflow.com/questions/12045540
复制相似问题