adamfoneil / Dapper.CX

A Crud library based on Dapper
MIT License
8 stars 1 forks source link

would be nice if there were insert and update delegates available with MergeAsync #35

Closed adamfoneil closed 3 years ago

adamfoneil commented 3 years ago

That way you could have dedicated insert and update behavior in cases when I can't use my convention base classes that use IAudit

adamfoneil commented 3 years ago

This will really impact SaveAsync because Merge calls Save internally.

adamfoneil commented 3 years ago

this might be a little better if the model arg were part of the delegate. This is so you can save (or merge) a new model instance inline within the method call, and still leverage the new delegates. Here's what the new delegate looks like in use:

var annotation = new Annotation()
{
    DocumentId = documentId,
    Content = xfdf
};
await cn.MergeAsync(annotation, onSave: (action) => TrackedRecord.Update(action, annotation, User.Identity.Name));

I'd prefer I could write it like this:

await cn.MergeAsync(new Annotation()
{
    DocumentId = documentId,
    Content = xfdf
}, onSave: (action, model) => TrackedRecord.Update(action, model, User.Identity.Name));