Reputation: 142
I have the following sql statement that I am trying to get into LINQ
update MyTable
set MyValue = Convert(int, MyValue) + 1
output deleted.MyValue
where MyKey = 'Number'
I've searched high and low, and am unable to find a way to do this SQL statement in LINQ with proper results.
Upvotes: 1
Views: 122
Reputation: 103375
You can try the following:
var queryMyTable =
from t in db.MyTable
where t.MyKey == "Number"
select t;
foreach (var t in queryMyTable)
{
Console.WriteLine(t.MyValue); // equivalent to output deleted.MyValue
t.MyValue = Convert.ToDouble((Convert.ToInt32(t.MyValue) + 1));
}
db.SubmitChanges();
Upvotes: 1