Hello I am developing one wpf application. I am using linq to sql for all database operations.
Now I want to update multiple record simultaneously from list of records by comparing their primary key.
i.e. in sql server 2005
we pass one xml to procedure and we open it and update records like
SELECT * INTO #TMP FROM openxml(Myxml);
UPDATE myPhysicalTable SET
myColumnName = #TMP.myColumnName
, myColumnName1 = #TMP.myColumnName1
FROM #TMP
WHERE myPhysicalTable.pkid = #TMP.pkid
now I want to do same here from linq to sql then please suggest proper way.
Linq to sql does not support set based operations out of the box. So you need to something like this
Update
As for your comment, yes: it will be less efficient than the UPDATE in SQL. Linq to Sql will send one update statement for each update. Even if you call SubmitChanges() only once you will get the separate updates (but in one transaction).
So you might want to reconsider using Linq2sql for this particular operation, especially if you have large sets.