嗨所有 如何在linq expresion中使用unicode字符作为列名? :(
mytable.Compute( Sum( + myColumnName + ), ));注意:我的专栏名称是波斯语 面对这个问题: 抛出类型'System.Data.SyntaxErrorException'的异常int 这条线对于非-unicode列名称是可以的,我可以通过这个表达我的相关列的总和!!!!! 我的unicode列名称可以与Space分开相同作为 ColumnnamePart1 ++ columnNamePart2
解决方案如果你想使用Linq,请使用与此类似的句子:
var qry = myTable.AsEnumerable()。Sum(a => a.Field< data_type>( FieldName));注意,那你需要用适当的 data_type bb483010.aspx>数据类型 [ ^ ] 和 FieldName 具有正确的字段名称。 顺便说一下,你需要知道字符串是不可变的。我建议使用 String.Concat [ ^ ]方法:
mytable.Compute( string .Concat( Sum(,myColumnName, ) ), ));注意:如果你的列名包含空格,我建议在列名周围使用 [] 来解决它。
hi to all how can i use unicode character as column name in linq expresion ??? :(
mytable.Compute("Sum(" + myColumnName + ")", ""));Note: my column name is Persian face with this problem : threw an exception of type 'System.Data.SyntaxErrorException' int and this line is ok for Non -unicode Column name and i can sum of my related column by this expresion !!!!! my unicode column name can separate With Space same As ColumnnamePart1 + " " + columnNamePart2
解决方案 If you want to use Linq, please use sentence similar to this one: var qry = myTable.AsEnumerable().Sum(a=>a.Field< data_type>("FieldName"));Note, that you need to replace: data_type with proper data type[^] and FieldName with proper field name. By The Way, you need to know that string is immutable. I'd suggest to use String.Concat[^] method:
mytable.Compute(string.Concat("Sum(", myColumnName , ")"), ""));Note: if your column name contains space, i'd suggest to use [] around column name to workaround it.
更多推荐
如何在linq表达中使用唯一字符
发布评论