C#: SQL Query Builder Class

后端 未结 5 1061
一整个雨季
一整个雨季 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

    Mohammed Hadi, with DbExtensions your sample can be like this:

        public static string InsertQuery(string into, NameValueCollection values)
        {
            var query = SQL
                .INSERT_INTO(into + " (" +
                             String.Join(" ,", values.Keys.Cast().ToArray()) + 
                             ")")
                .VALUES(values.Keys.Cast().Select(key => values[key]));
    
            return query.ToString();
        }
    

提交回复
热议问题