Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to submit changes in LinqPad

Tags:

c#

oracle

linqpad

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); 
like image 759
bangoo Avatar asked Aug 26 '13 07:08

bangoo


People also ask

How do I commit changes to the database in LINQPad?

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.

What is the data context in LINQPad?

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.

What is LINQ to SQL submitchanges?

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 do I submit changes to the database?

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.


1 Answers

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(); } 
like image 79
Erwin Avatar answered Sep 22 '22 22:09

Erwin