如何在linq表达中使用唯一字符

编程入门 行业动态 更新时间:2024-10-27 14:26:00
本文介绍了如何在linq表达中使用唯一字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嗨所有 如何在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表达中使用唯一字符

本文发布于:2023-11-30 18:00:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1650993.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符   如何在   linq

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!