on-internet
← Community

Performing MERGE with Dapper.net

Stack Overflow ·

We are using Dapper.net for the data layer in an ASP.net MVC 5 app. One operation requires the use of the MERGE command (if the TitleID exists, update the record, if it doesn't, insert it) - something like this: MERGE BookInventory bi USING BookOrder bo ON bi.TitleID = bo.TitleID WHEN MATCHED THEN UPDATE SET bi.Quantity = bi.Quantity + bo.Quantity WHEN NOT MATCHED BY TARGET THEN INSERT (TitleID, Title, Quantity) VALUES (bo.TitleID, bo.Title,bo.Quantity); Can Dapper be used to map values onto this MERGE statement? I can't find anything on this and it's unclear what the best approach to using ME

Comments

Sign in or sign up to comment and upvote.

No comments yet.