0

Working with LINQPad 5 on virtual machine win 10. Select queries work, now I try to use update query and it gives me an error about SubmitChanges() method.

CS0103 The name 'SubmitChanges' does not exist in the current context.

Basically all answers that I found are like this: write SubmitChanges() or SaveChanges() if you are using EF. Also I tried to change from C# Statements to C# Program.

How to submit changes in LinqPad

In one answer user might not add a connection, which I did. (screen 1) LINQpad: Global function SubmitChanges not found

Then I tried to pass a "this" to a method, and in my case "this" is an UserQuery, not a DataContext. (screen 2) Which is wierd.

linqpad - SubmitChanges Extension

void Main()
{
var ret =from t in Tbblankimages where t.Comment == "1234" select     t;    
var im = ret.First();   
MemoryStream ms = new MemoryStream();
using (FileStream file = new     FileStream("E:\\saved.jpg",FileMode.Open,System.IO.FileAccess.Read))
{
file.CopyTo(ms);
}
byte[] imageData= ms.ToArray();
im.Image = imageData;   
Test(this);
}
static void Test(System.Data.Linq.DataContext c)
{
 c.SubmitChanges();
}

Screenshots with error messages:

https://i.stack.imgur.com/GqJ1Z.jpg (screen 1)

https://i.stack.imgur.com/Ogcbi.jpg (screen 2)

Also I should add that the database is PostgreSQL and I use custom driver to it from here: https://github.com/fknx/linqpad-postgresql-driver Version of Postgresql is 11.3-4-windows-x64

Michael Snytko
  • 327
  • 3
  • 13

2 Answers2

3

With postgresql driver it works differently:

https://github.com/fknx/linqpad-postgresql-driver

   var user = Users.Single(u => u.Id == 42);

   user.Emailaddress = "john.doe@abc.com";

   this.Update(user);
Michael Snytko
  • 327
  • 3
  • 13
0

Sometimes Linqpad disconnects and causes this problem.
I click on the top left Refresh button to solve this problem.
20190624152912.png

Wei Lin
  • 3,591
  • 2
  • 20
  • 52