How to compare ntext type in sql server 2005 with string with linq?
in SQL Server 2005
@a as ntext
linq in C #;
string b; var k=from p in DataContext.TableName where p.a.toString()==b) select p; //return k=null
NTEXT columns cannot be compared. See MSDN and MSDN Forum
If you work in 2005 or higher, convert NTEXT to NVARCHAR (MAX), as others have already pointed out.
You can do this in linq2sql using the static "Like" method of the System.Data.Linq.SqlClient.SqlMethods class.
string b; var k=from p in DataContext.TableName where System.Data.Linq.SqlClient.SqlMethods.Like(p.a, b) select p;
linq2sql, - .ToString() , , .
, , NVARCHAR (MAX) NTEXT