AuditTrail for ExecuteDelete
Hello,
I used ASP.NET Maker 2022. Audit Trail was not created when using method
int affected = ExecuteDelete("Books", new { Id = 1 });
But it's working in RowDeleted().
Any help would be appreciated.
Thanks
Hello,
I used ASP.NET Maker 2022. Audit Trail was not created when using method
int affected = ExecuteDelete("Books", new { Id = 1 });
But it's working in RowDeleted().
Any help would be appreciated.
Thanks
If you have enabled audit trail for the table, just use the table's Delete method directly. For example:
int affected = Resolve("Books").Delete(data);
I'm calling ExecuteDelete() inside RouteAction which triggered by api using jquery.get.
The record was deleted but Audit Trail was not created.
Did you try?
If you have enabled audit trail for the table, just use the table's Delete method directly. For example:
int affected = Resolve("Books").Delete(data);
what (data) should I put?
I tried
int affected = Resolve("Books").Delete( { Id = 1 } );
It doesn't work, affected always return 0 and record was not deleted.
Make sure that the field name/value is correct. Also enable debug mode (Tools -> Advanced Settings -> Debug) to check for any errors.
my script:
app.MapGet("/api/delQueue/{guid}", (string guid) => {
int affected = ExecuteDelete("Queue", new {Guid = guid} ); // working, affected=1, record deleted
//int affected = Resolve("Queue").Delete( new {Guid = guid} ); // failed, affected=0, record not delete
return affected;
});
with debug mode, all SQL scripts were shown but not the script in app.MapGet.
To see why the codes are not working, open your project with Visual Studio, add a break point to the Delete method of the "Queue" table (located in "Models/Queue.cs"), step through the codes and debug from there.
Thanks, problem solved.
new script:
app.MapGet("/api/delQueue/{guid}", (string guid) => {
var row = ExecuteRow("select id from Queue where Guid='"+guid+"'");
int res = Resolve("Queue").Delete(row);
return res;
});