c# - How get the biggest number? -


i trying biggest number field in database using code:

var bb=(from c in office_tbls select c.codenumber).max(); 

when run query receive result "999" wrong because biggest number in databse 1601. datatype being nvarchar in field of database matter?

how fix code correct max number.

since using linq sql should use convert.toint32 converting string number, query be:

var bb =(from c in office_tbls select convert.toint32(c.codenumber)).max(); 

see: standard query operator translation

c# casts supported in projection. casts used elsewhere not translated , ignored. aside sql function names, sql performs equivalent of common language runtime (clr) convert. is, sql can change value of 1 type another. there no equivalent of clr cast because there no concept of reinterpreting same bits of type. why c# cast works locally. not remoted.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -