views:

155

answers:

1

I'm using a GridView and a LinqDataSource to view the Categories table. I set the Gridview to enable sorting. Sorting generally works except when i clicked on the header of the Description column.

"An order by expression can only contain non-constant scalars that are order comparable by the server. The expression with type 'NText' is not order comparable."

Description is casted with ntext but can someone explain to me what's happening? why does NText is not sortable when nvarchar are?

+1  A: 

SQL Server just doesn't let you order by NText fields (see also error 420 in the SQL Server Error List). My guess is that it's for efficiency reasons, but I couldn't say for sure.

Now the solution in the linked article is cast to nvarchar... but that's obviously pretty hard to do in LINQ.

Does your description field definitely need to be an ntext?

Jon Skeet
nope it doesn't. I just wanted to know what was happening. Thanks jon! You're so close to reaching 100,000 points!
burnt1ce