C#: SQL Query Builder Class

后端 未结 5 1070
一整个雨季
一整个雨季 2021-02-14 01:11

Where can I find a good SQL Query builder class. I just need a simple class to build a SQL string and that is it. I will need it for C# and MySql. I really don\'t need anything

5条回答
  •  星月不相逢
    2021-02-14 01:31

    If you are using .NET 4 and don't mind using dynamics you can use Massive, created by Rob Conery, this single file Database requires no dlls, just drop the Massive.cs file and you ready to go.

    You can use the Massive to build queries like this.

    //grab all the products
    var products = table.All();
    //Or
    var productsFour = table.All(columns: "ProductName as Name", where: "WHERE categoryID=@0",args: 4);
    

    You can also run ad-hoc queries as needed:

    var result = tbl.Query("SELECT * FROM Categories");
    

提交回复
热议问题