简体   繁体   中英

Sorting a Nullable Biginit is returning wrong sorted data

I have a column inside my sql server 2008 R2 of type Biginit that allow nulls named “Serial”. It has values such as :-:-

**Serial**
100200
100202
100375
100376
100377

Now inside my asp.net mvc web application, I have the following linq query inside the entity framework :-

var records = repository.AllFind(withOutSpace).OrderBy(a => a.Technology.Serial).ToPagedList(page, pagesize);

so I am ordering the the records ascending based on the Serial number , but the result was that I got the following order

100375
100376
100377
100200
100202

So it assumed that 100200 is grater than 100377 !!, any idea what might be causing this issue ? Thanks

If it is taking 100200 as bigger than 100377 then, he is sorting lexicographically, like if the elements were string.

Lexicographycally, 100200 is greater than 100377, and maybe this is the reason.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM