How to submit changes in LinqPad
Asked Answered
P

2

60

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);
Publisher answered 26/8, 2013 at 7:34 Comment(4)
Did you try SaveChanges();? What have you tried? Any errors?Agitato
That's my problem. I don't know where I can call SaveChanges or somethin similar.Publisher
Query your db, change value of record, call SaveChanges() ...Agitato
No problem, made it into an answer for future reference.Agitato
A
83

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();
}
Agitato answered 26/8, 2013 at 12:16 Comment(6)
it should be SubmitChanges()Roue
SubmitChanges for Linq-to-SQL and SaveChanges for Entity Framework.Agitato
You can also just change to "C# Statements" and leave out the Main function.Lippmann
He's asking for IQ driver, so SubmitChanges is correctEll
No need for it to be switched to C# Program. C# Statement(s) works as well. See https://mcmap.net/q/326340/-how-to-submit-changes-in-linqpad @Adrian's answer below.Goof
what if I have a composit object because of a Join?Deejay
I
18

If you are using an EF Context, then you need to call SaveChanges()

If you are using a Linq2Sql context, then you need to call SubmitChanges()

Impervious answered 2/1, 2019 at 16:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.