public void FillCommand_ThrowsIfIncompleteFact() { var command = new SqlCommand(); var builder = new SqlExpressionBuilderSelect(); var fromTable = new Table("table", "t"); var param = new SqlParameter("@bla", SqlDbType.VarChar); builder.From(fromTable); builder.Where("t.col = @bla", new[] { param }); Assert.Throws <Exception>(() => builder.FillCommand(command)); }
public void FillCommand() { var command = new SqlCommand(); var builder = new SqlExpressionBuilderSelect(); var fromTable = new Table("table", "t"); var param = new SqlParameter("@bla", SqlDbType.VarChar) { Value = 5 }; builder.From(fromTable); builder.Where("t.col = @bla", new[] { param }); builder.FillCommand(command); Assert.Equal(1, command.Parameters.Count); Assert.Equal(param, command.Parameters.Cast <SqlParameter>().First()); Assert.Equal(builder.ToString(), command.CommandText); }