Jeff-Lewis / codesmith

Automatically exported from code.google.com/p/codesmith
0 stars 0 forks source link

PLINQO - LastAudit and database errors #117

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

In the code snipped below I load 2 entities from the database and update
their properties. Then saving the changes to the database and displaying
the audit log. All is fine unless you get an error. Line 11 causes the
foreign key constraint error, but the audit log still reports this update
even though database record has not been updated.

1.  Webc.Data.WebCodaCmsDataContext ctx = new Webc.Data.WebCodaCmsDataContext();
2.
3.  var website = ctx.Manager.WebSite.GetByKey("WCODA");
4.  var page = ctx.Manager.Page.GetByWebSiteCode("WCODA").First();
5.  
6.  try {
7.      
8.      website.DateLastUpdated = DateTime.Now;
9.  
10.     page.DateLastUpdated = DateTime.Now;
11.     page.WebSiteCode = "DOES NOT EXIST"; // foreign key violation
12. 
13.     ctx.SubmitChanges();
14. 
15. } catch (Exception e2){
16.     Console.WriteLine(e2.Message);
17. }
18. 
19. Console.WriteLine("LOG");
20. if (ctx.LastAudit == null) {
21.     Console.WriteLine("LOG IS NULL");
22. } else {
23.     Console.WriteLine(ctx.LastAudit.ToXml());
24. }
25. 
26. ctx.Dispose();

What is the expected output? What do you see instead?

Should the audit log only display the committed updates?

What version of the product are you using?

V 3.0.687

Original issue reported on code.google.com by webc...@gmail.com on 21 Jul 2009 at 5:05

GoogleCodeExporter commented 9 years ago

Original comment by ejsm...@gmail.com on 28 Jul 2009 at 3:51

GoogleCodeExporter commented 9 years ago
Hi,  The audit log is built from the change list off the DataContext.  When 
DataContext.SubmitChanges is called, it is done as a transaction.  So, either 
the whole 
audit log is valid or not.  If the submit failed, the audit log will still 
contain the 
changes made to the DataContext.  It is update the developer to determine when 
to save 
and how to use the audit log.  Does this help?

Original comment by paul.wel...@gmail.com on 11 Aug 2009 at 2:00

GoogleCodeExporter commented 9 years ago
Thanks.

Original comment by oleg.put...@gmail.com on 2 Sep 2009 at 3:03