I have a problem with committing changes in LinqPad. I am using Oracle database over IQ driver in LinqPad. I can retrieve data but I don't know how to submit changes to database.
I retrieve data from database:
var items = Asyncqueue.Where(x => ids.Any(y=> y == x.Asyncqueueid)); // then I have to fix data
I have tried to set submit action like this:
Asyncqueue.SetSubmitAction(items, SubmitAction.Update);
Because there is no data context readily available to you (and no .dbml file) in LINQPad, the way you go about this is slightly different. There is a globally-scoped subroutine, "SubmitChanges()," that should be called whenever you wish to commit an action to the database.
This data context is in charge of maintaining your database connection and is what you use to submit changes to the database. Because there is no data context readily available to you (and no .dbml file) in LINQPad, the way you go about this is slightly different.
When you call SubmitChanges, LINQ to SQL examines the set of known objects to determine whether new instances have been attached to them. If they have, these new instances are added to the set of tracked objects.
How to: Submit Changes to the Database. Regardless of how many changes you make to your objects, changes are made only to in-memory replicas. You have made no changes to the actual data in the database. Your changes are not transmitted to the server until you explicitly call SubmitChanges on the DataContext.
Change Language in LINQPad to "C# Program" and use the following code
void Main() { var p1 = Person.Single(x => x.Id == 1); p1.Name = "Test"; SubmitChanges(); }
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