c# - Updating a NVarChar(MAX) column with Linq causing an error -
i trying create update on existing value in database using linq in c#.
i instantiate variable:
var projecttrackingentity = context.project_trackings.single(pt => pt.project_id == projectid);
then update action column(it nvarchar(max)
), checking if has action. if add together on semi-colon eg. action1;action2
when call:
context.submitchanges();
i error while debugging:
system.notsupportedexception: sql server not handle comparing of ntext, text, xml, or image info types.
i have tried setting updatecheck = updatecheck.never
, doesn't prepare problem.
edit: adding code update actions (the variable "action" string)
var actions = projecttrackingentity.action.split(';'); bool equalactions = false; foreach (string 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 prepare issue open dbml file
xml editor
, set updatecheck never
follows:
<column canbenull="true" dbtype="xml" name="permissionsxml" type="system.xml.linq.xelement" updatecheck="never"></column>
method 2:
change field in varchar(max)
method 3:
change updatecheck updatecheck.whenchanged
i hope help you.
c# linq
No comments:
Post a Comment