I am trying to make an update on an existing value in my database using Linq in C#.
I instantiate the variable:
var projectTrackingEntity = context.project_trackings.Single(pt => pt.project_id == projectId);
Then I update the action column(it is a NVarChar(MAX)), but I am checking if it already has an action. If so I just add on to it with a semi-colon eg. action1;action2
When I call:
context.SubmitChanges();
I get this error while debugging:
System.NotSupportedException: SQL Server does not handle comparison of NText, Text, Xml, or Image data types.
I have tried setting UpdateCheck = UpdateCheck.Never, but that doesn't fix the problem.
EDIT: Adding the code where I update the actions (the variable "action" is a string)
var actions = projectTrackingEntity.action.Split(';');
bool equalActions = false;
foreach (string a in actions)
{
if (string.Equals(a, action, StringComparison.CurrentCultureIgnoreCase))
{
equalActions = true;
break;
}
}
if(!equalActions)
{
projectTrackingEntity.action = string.IsNullOrEmpty(projectTrackingEntity.action) ? //if
action : //true
projectTrackingEntity.action + ';' + action; //false
}
context.SubmitChanges();
Method 1:
For fix this issue just open the dbml file with xml editor and set the updatecheck to Never as follows:
<column canbenull="true" dbtype="Xml" name="PermissionsXml" type="System.Xml.Linq.XElement" updatecheck="Never"></column>
Method 2:
Change your field in to a VARCHAR(max)
Method 3:
change UpdateCheck to UpdateCheck.WhenChanged
I hope this will help to you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With