且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

linqpad-SubmitChanges扩展

更新时间:2023-11-26 21:13:58

您可以通过将当前上下文(this)传递到静态方法中来实现:

You can do it with the by passing the current Context (this) into the static method:

您的程序:

void Main()
{
    //Do Stuff  
    ConfirmSubmitChanges(this);
}

我的扩展程序.linq 中:

static void ConfirmSubmitChanges(DataContext context)
{
    if (MessageBox.Show("Submit Changes?", "OK?", MessageBoxButtons.YesNo) == DialogResult.Yes)
    {
        context.SubmitChanges();
        "Saved".Dump();
    }
}