LINQ to SQL: Transactions verwenden
Das Verwenden von Transactions in LINQ-to-SQL ist total simple:
using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope()) {
SomeDatabaseDataContext ctx = new SomeDatabaseDataContext();
ctx.SomeEntities.InsertOnSubmit(new SomeEntity());
ctx.SubmitChanges();
ts.Complete();
}
Wichtig ist,das man den Aufruf von ts.Complete() nicht vergisst. Sonst wird ein Rollback auf die Transaktion gemacht!
Für den TransactionScope braucht man eine Referenz auf die System.Transactions.dll.
MCP 070-562 (.NET 3.5; ASP.NET Application Development) geschafft
![]() |
Heute morgen habe ich mit 826 Punkten meine MCP Prüfung zum MCTS: Microsoft .NET Framework 3.5, ASP.NET Application Development bestanden! Nicht so gut habe ich bei "Working with ASP.NET AJAX and Client-Side Scripting" abgeschnitten, dafür habe ich aber bei "Configuring and Deploying Web Applications" und "Targeting Mobile Devices" voll reingehauen. Nun darf ich auch überall ein tolles MCTS Logo draufpappen:
|

