I am trying to do the equivalent of an SQL UPDATE with C# statements in linqpad but the data doesn't change and I'm not sure to even debug it further to figure out why. The User table is pretty standard with just a string to store Sid.
var usersWithSid = from u in Users where u.Sid != null select u;
foreach(var u in usersWithSid) {
u.Sid = "S-1-5-21-3812666658-2998621725-2245962016-6618";
}
SubmitChanges();
usersWithSid.Dump();
Most of the examples I have found seem to only update one record at a time. Why doesn't this work?
First, specify the table name that you want to change data in the UPDATE clause. Second, assign a new value for the column that you want to update. In case you want to update data in multiple columns, each column = value pair is separated by a comma (,). Third, specify which rows you want to update in the WHERE clause.
For each query, LINQPad creates a separate server, which a class that runs in its own process and executes the query in isolation. This isolation prevents queries from interfering with each other (or the UI) and allows LINQPad to safely cancel a query without polluting other application domains.
Do you have a primary key defined on the table? The updates will silently fail if you don't.
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