Using the amazing LinqPad. Is there a way to clear all pending database changes to the built-in LinqToSql DataContext
(the UserQuery
object which is this
)?
Example LinqPad file, connection to a basic mssql database with tb_person
table.
void Main()
{
var newRow = new tb_person() {FirstName = "Bob"};
// do lots of db updates, deletes, inserts....
tb_persons.InsertOnSubmit(newRow);
// how to do this, revert all pending Db changes?
//this.SomeMethodToDiscardChanges()
}
I found 2 option, neither seems to be ideal, maybe there is a LinqPad specific way outside of LinqToSql?
- Create a new DataContext, how to do this in LinqPad?
DataContext.Refresh()
method passing in every added or changed entity, cumbersome!
References
How to clear the DataContext cache on Linq to Sql