"Argument data type ntext is invalid for argument 1 of upper function" when trying to add a third item to a filter

c# entity-framework linq

Question

On the ASP.NET website, I have been studying the Contoso University course. I choose to try adding a third option to the filter since I am trying to improve my abilities. The instruction gives:

if (!String.IsNullOrEmpty(searchString))
{
    students = students.Where(s => s.LastName.ToUpper().Contains(searchString.ToUpper())
                           || s.FirstMidName.ToUpper().Contains(searchString.ToUpper()));
}

Consider that I have a third column labeled Nickname. I made an attempt to include this in the filter by including an extra || operator:

if (!String.IsNullOrEmpty(searchString))
{
    students = students.Where(s => s.LastName.ToUpper().Contains(searchString.ToUpper())
                           || s.FirstMidName.ToUpper().Contains(searchString.ToUpper())
                           || s.Nickname.ToUpper().Contains(searchString.ToUpper()));
}

I obtain: after running with the third option added:

[SqlException (0x80131904): Argument data type ntext is invalid for argument 1 of upper function.]

What do I not see here? What else must I discover in order to better comprehend what is going on here?

1
3
3/12/2013 2:51:15 PM

Popular Answer

I can remember seeing issues with NTEXT columns in the past when using Entity Framework. I now only ever use NVARCHAR to avoid this (MAX). I'm not sure if that would be helpful in your case—whether you are able to modify the database type or not—but in any case, there is further information here:

Utilizing ToLower() on NText fields when using Linq to Entities

2
5/23/2017 10:29:08 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow