"参数的数据类型NTEXT是上层函数"的参数1无效;试图到第三项添加到过滤器时 [英] "Argument data type ntext is invalid for argument 1 of upper function" when trying to add a third item to a filter
问题描述
我一直在关注ASP.NET网站上的Contoso大学教程。我想扩大我的技能,并因此决定尝试添加第三个选择的过滤器。本教程提供:(!String.IsNullOrEmpty(搜索字符串))
如果
{
=学生学生。凡(S =方式>。s.LastName.ToUpper()包含(searchString.ToUpper())
|| s.FirstMidName.ToUpper()包含(searchString.ToUpper()));
}
比方说,我有一个外号叫第三列。我试图通过增加一个额外添加此到滤波器||运营商:(!String.IsNullOrEmpty(搜索字符串))
如果
{
=学生students.Where (S =方式> s.LastName.ToUpper()包含(searchString.ToUpper())
|| s.FirstMidName.ToUpper()包含(searchString.ToUpper())
||秒。 。.Nickname.ToUpper()包含(searchString.ToUpper()));
}
在我的第三个选项运行加入我得到:
[SQLEXCEPTION(0x80131904):参数的数据类型NTEXT是上层函数的参数1无效]
我缺少的是在这里吗?我需要什么学习旁边帮助我更加了解这里发生了什么?
我记得有之前NTEXT列问题使用实体框架时。为了解决这个问题,我现在只会使用NVARCHAR(MAX)。我不知道这是否会有助于您的具体情况..你是否能够改变DB型或不...否则还有进一步的信息在这里:
LINQ到实体:对NTEXT领域 <使用ToLower将() / p>
I have been following the Contoso University tutorial on the ASP.NET website. I am trying to expand my skills and so decided to try adding a third option to the filter. The tutorial provides:
if (!String.IsNullOrEmpty(searchString))
{
students = students.Where(s => s.LastName.ToUpper().Contains(searchString.ToUpper())
|| s.FirstMidName.ToUpper().Contains(searchString.ToUpper()));
}
Let's say I've got a third column called Nickname. I tried adding this to the filter by adding an additional || 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()));
}
When I run with the third option added I get:
[SqlException (0x80131904): Argument data type ntext is invalid for argument 1 of upper function.]
What am I missing here? What do I need to learn next to help me understand more about what's happening here?
I recall having problems with NTEXT columns before when using Entity Framework. To get around this, I now only ever use NVARCHAR(MAX). I am not sure whether that would help in your situation.. whether you are able to change the db type or not... otherwise, there is further info here:
Linq to Entities : using ToLower() on NText fields
这篇关于"参数的数据类型NTEXT是上层函数"的参数1无效;试图到第三项添加到过滤器时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!