1
votes

Some background: I'm writing a Winforms based LOB application and have read a lot of "hate" towards datatables, datasets, tableadapters, etc. I'm not a huge fan of OR\M's, but found dapper to be great. I get the speed of pure ADO without writing ADO.

The question: I need to maintain object state to know whether it's an insert, update, or delete.

How would you go about this? An enum field of the object you set in the form when certain buttons are pushed maybe?

Any thoughts are greatly appreciated!

1
Why not have two properties: IsDeleted, IsModified. You'll know its a new (INSERT) object because it won't have a primary key yet.maccettura

1 Answers

2
votes

Along with the comments from @maccettura above, I would look into using an additional Dapper extension - Dapper.Contrib.

Dapper.Contrib contains a number of helper methods for inserting, getting, updating and deleting records.

You can set things up via convention or attributes.