Drizin / InterpolatedSql

Sql Builder using Interpolated Strings
MIT License
106 stars 7 forks source link

Updating DB Keywords #2

Closed mcflie1994 closed 9 months ago

mcflie1994 commented 1 year ago

Thank you very much for this wonderfully simple library. Are there any plans to implement functions for keywords like UPDATE, SET, INSERT INTO etc? I would love to be able to use this library on more than just a reading level. Am I just missing this or is there a reason it is not provided?

Drizin commented 1 year ago

Hi @mcflie1994 Can you provide an example of what you're trying to achieve? Did you check the Static Command examples?

var cmd = cn.CommandBuilder($"DELETE FROM Orders WHERE OrderId = {orderId};");
int deletedRows = cmd.Execute();
var cmd = cn.CommandBuilder();
cmd += $"DELETE FROM Orders WHERE OrderId = {orderId}; ";
cmd += $"INSERT INTO Logs (Action, UserId, Description) VALUES ({action}, {orderId}, {description}); ";
cmd.Execute();

PS: DapperQueryBuilder is being deprecated and this repo will be archived soon. The replacement library is InterpolatedSql.Dapper. I'll move this issue to that new repo.

Drizin commented 1 year ago

In the new library the aforementioned examples are here: https://github.com/Drizin/InterpolatedSql/blob/main/Builders.md#static-command And you should use .SqlBuilder() instead of .CommandBuilder().

Drizin commented 1 year ago

There's a new InsertUpdateBuilder. Sample usage here