static void Main(string[] args) { ILayout layout = new LayoutSqlServer(); IResultBuilder result0 = Builders.SelectFrom(layout, "test") .Columns("column1, column2") .Where <SqlParameter, int>("column1", 1) .OrWhere <SqlParameter, int>("column2", 2) .WhereNull("column1") .WhereBetween("column1", new SqlParameter("@p1", 1), new SqlParameter("@p2", 1)) .Builder(); IResultBuilder result1 = Builders.InsertFrom(layout, "test") .Columns("column1", "column2") .Values(new SqlParameter("@column1", 1), new SqlParameter("@column2", 1)) .Identity() .Builder(); IResultBuilder result2 = Builders.UpdateFrom(layout, "test") .SetValue("column1", new SqlParameter("@column1", 1)) .SetValue("column2", new SqlParameter("@column2", 2)) .Where("id", new SqlParameter("@id", 1)) .WhereNull("id") .Builder(); IResultBuilder result3 = Builders.DeleteFrom(layout, "test") .Where <SqlParameter, int>("id", 10) .WhereNull("id") .WhereBetween("column1", new SqlParameter("@p1", 1), new SqlParameter("@p2", 1)) .Builder(); Console.WriteLine(result0.Sql); Console.WriteLine(result1.Sql); Console.WriteLine(result2.Sql); Console.WriteLine(result3.Sql); Console.ReadKey(); }
static void Main(string[] args) { //var builder = FlepperQueryBuilder // .Insert() // .Into("Table1") // .Columns("Column1") // .Values("Value1") // .WithScopeIdentity() // .BuildWithParameters(); IDbConnection dbConnection = new SqlConnection("Server=.\\SqlExpress;Database=QueryBuilderDatabase;User Id=sa;Password=senha;MultipleActiveResultSets=true;"); ILayout layout = new LayoutSqlServer(); #region Layout SqlParameter Created = new SqlParameter("@Created", SqlDbType.DateTime) { IsNullable = true, SourceColumnNullMapping = true, Value = DateTime.Now.Date.AddDays(-1) // DBNull.Value }; SqlParameter Name = new SqlParameter("@Name", SqlDbType.VarChar, 50) { Value = "Maria Aparecida Dias Cintra" }; SqlParameter Id = new SqlParameter("@Id", SqlDbType.Int) { Value = 2 }; SqlParameter Active = new SqlParameter("@Active", SqlDbType.Bit) { Value = true }; #endregion IResultBuilder resultSelect0 = Builders .SelectFrom(layout, "Owe") .Where <SqlParameter, int>("Id", 2) .OrWhere <SqlParameter, int>("Id", 10, "@p1") .Builder(); IResultBuilder resultSelect1 = Builders .SelectFrom(layout, "Credit") .Where <SqlParameter, int>("Id", 100) .Builder(); var abc = Builders.DeleteFrom(layout, "") .Where <SqlParameter, int>("Id", 1) .OrWhere <SqlParameter, int>("Id", 10, "@p00") .Builder(); var a1 = dbConnection.Query <Owe>(resultSelect0); var a2 = dbConnection.Query <Credit>(resultSelect1); var aaa = 100; //var r = dbConnection.InsertToInt(resultInsert); //IResultBuilder resultUpdate = Builders.UpdateFrom(layout, "Owe") // .SetValue("Created", Created) // .Where("Id", Id) // .Builder(); ////var id = dbConnection.Update(resultUpdate); //var resultDelete = Builders.DeleteFrom(layout, "Owe") // .Where("Id", Id) // .Builder(); //var a = dbConnection.Update(resultDelete); //Console.WriteLine(a); //dbConnection.Execute(resultUpdate); //DynamicParameters parameter = new DynamicParameters(); //parameter.Add("Name", "ccc NULL", DbType.String, ParameterDirection.Input); //parameter.Add("Created", null, DbType.Date, ParameterDirection.Input); //parameter.Add("Active", true, DbType.Boolean, ParameterDirection.Input); //var ra = dbConnection.Execute("INSERT INTO Owe(Name, Created, Active) VALUES(@Name, @Created, @Active)", parameter); IResultBuilder result = Builders .SelectFrom(layout, "Owe") .Builder(); IList <Owe> listOwe = dbConnection.Query <Owe>(result); var dados = dbConnection.Query(result); Console.ReadKey(); }