So, I used this method to insert records into my database:
TransactionBlock.Connection.Execute(
"INSERT Table(Item,Id)VALUES(@Item, @Id);
new {Item,Id = id }, TransactionBlock.Transaction);
Now I need to change this to first check if Item / id is in the database using the following:
const sql = "IF EXISTS (SELECT * FROM Table, where Item = @Item ... etc. etc.
but I did not find examples of how to achieve this. I can achieve this by creating a stored procedure, but I would like to try to implement this approach.
source
share