Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete a db row in LINQPAD

Tags:

linqpad

Total NOOB question. I have been using the new linqpad for about 20 minutes now. Great!

But now i want to delete a row in the db. I am using a EF5.0 connection. I cant seem to find anything in the help files or on the net. The only thing I can find is DeleteOnSubmit which doesnt work with EF (as far as I can see). I have also tried DeleteObject which doesnt work either. This is what I have tried.

var co = Companies.First();
co.Dump();

Companies.DeleteObject(co);
like image 635
Greg Avatar asked Sep 07 '13 13:09

Greg


1 Answers

This is old... and I don't know if/when this was added (probably in response to this exact scenario)… but you can accomplish this (in your given example) as follows:

//test the following line to ensure the context doesn't complain about the .First() reference

Companies.DeleteOnSubmit(Companies.First()); 

Companies.Context.SubmitChanges();
like image 156
azarc3 Avatar answered Sep 30 '22 20:09

azarc3