Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi to all
how can i use unicode character as column name in linq expresion ??? :(

C#
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
Posted
Updated 27-Mar-15 23:15pm
v5
Comments
Tomas Takac 28-Mar-15 8:27am    
I don't think this is LINQ. If you are using SQL Server try escaping the column name using square brackets: sum([myColumnName]).

1 solution

If you want to use Linq, please use sentence similar to this one:
C#
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:
C#
mytable.Compute(string.Concat("Sum(", myColumnName , ")"), ""));


Note: if your column name contains space, i'd suggest to use [] around column name to workaround it.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900