Ntext 和 Image 数据类型不能用于 WHERE、HAVING、GROUP BY、ON 或 IN 子句

问题描述:

我收到一个错误:

ntext 和 image 数据类型不能用于 WHERE、HAVING、GROUP BY、ON 或 IN 子句,除非这些数据类型与 LIKE 或IS NULL 谓词同时尝试保存对 SQLCE 表的更改.

The ntext and image data types cannot be used in WHERE, HAVING, GROUP BY, ON, or IN clauses, except when these data types are used with the LIKE or IS NULL predicates while trying to save the changes to SQLCE tables.

请注意这是一个更新操作.

Please note this is an update operation.

我安装了 SQLCE 3.5.1.0 版.

I have version 3.5.1.0 of SQLCE installed.

以下是代码的错误消息和堆栈跟踪:

Below is the error message and stack trace with the code:

System.Data.SqlServerCe.SqlCeException未处理 Message=The ntext 和图像数据类型不能用于WHERE、HAVING、GROUP BY、ON 或 IN子句,除非这些数据类型与 LIKE 或 IS NULL 一起使用谓词.源=SQL Server紧凑型 ADO.NET 数据提供程序
HResult=-2147217900
本机错误=25923
堆栈跟踪:
在 System.Data.SqlServerCe.SqlCeCommand.CompileQueryPlan()
在 System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior行为,字符串方法,ResultSetOptions 选项)
在 System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery()
在 System.Data.Linq.SqlClient.SqlProvider.Execute(Expression查询,QueryInfo 查询信息,IObjectReaderFactory 工厂,Object[]parentArgs, Object[] userArgs,ICompiledSubQuery[] 子查询,对象最后结果)
在 System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression查询,QueryInfo[] queryInfos,IObjectReaderFactory 工厂,Object[]userArguments, ICompiledSubQuery[]子查询)
在 System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression查询)
在 System.Data.Linq.ChangeDirector.StandardChangeDirector.DynamicUpdate(TrackedObject项目)
在 System.Data.Linq.ChangeDirector.StandardChangeDirector.Update(TrackedObject项目)
在 System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode故障模式)
在 System.Data.Linq.DataContext.SubmitChanges(ConflictMode失败模式)

System.Data.SqlServerCe.SqlCeException was unhandled Message=The ntext and image data types cannot be used in WHERE, HAVING, GROUP BY, ON, or IN clauses, except when these data types are used with the LIKE or IS NULL predicates. Source=SQL Server Compact ADO.NET Data Provider
HResult=-2147217900
NativeError=25923
StackTrace:
at System.Data.SqlServerCe.SqlCeCommand.CompileQueryPlan()
at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options)
at System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery()
at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)
at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)
at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
at System.Data.Linq.ChangeDirector.StandardChangeDirector.DynamicUpdate(TrackedObject item)
at System.Data.Linq.ChangeDirector.StandardChangeDirector.Update(TrackedObject item)
at System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode)
at System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)

导致错误的代码:

var storedBug = DataContext.Bug_Tables.Where(b => b.Id.Equals(bugToSave.Id)).FirstOrDefaul(); 

storedBug.Name = bugToSave.Name;
storedBug.DeveloperId = bugToSave.Developer == null ? null : bugToSave.Developer.Id; 
storedBug.TesterId = bugToSave.Tester == null ? null : bugToSave.Tester.Id; 
storedBug.AssignedPersonId = bugToSave.AssignedPerson == null ? null : bugToSave.AssignedPerson.Id; 
storedBug.BugAreaId = bugToSave.BugArea.Id;
storedBug.BugStatusId = bugToSave.Status.Id;
storedBug.PriorityId = bugToSave.Priority == null ? null : bugToSave.Priority.Id; 
storedBug.Description = bugToSave.Description;
storedBug.Notes = bugToSave.Notes;
storedBug.Replication = bugToSave.Replication;
storedBug.FixedInBuild = bugToSave.FixInBuild;

DataContext.SubmitChanges();