oracle 如何在 LinqPad 中提交更改
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18438924/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to submit changes in LinqPad
提问by bangoo
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.
我在 LinqPad 中提交更改时遇到问题。我在 LinqPad 中通过 IQ 驱动程序使用 Oracle 数据库。我可以检索数据,但我不知道如何提交对数据库的更改。
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);
回答by Erwin
Change Language in LINQPad to "C# Program" and use the following code
将 LINQPad 中的 Language 更改为“C# Program”并使用以下代码
void Main()
{
var p1 = Person.Single(x => x.Id == 1);
p1.Name = "Test";
SubmitChanges();
}
回答by Adrian Grigore
If you are using an EF Context, then you need to call SaveChanges()
如果您使用的是 EF 上下文,则需要调用 SaveChanges()
If you are using a Linq2Sql context, then you need to call SubmitChanges()
如果您使用的是 Linq2Sql 上下文,则需要调用 SubmitChanges()