private void ConstructBody() { var usingBlock = new CSBlock("using (SqlCommand sqlCommand = new SqlCommand())"); string sqlString = $"${Quotes}{SqlSelectBuilder.CreateSelectByKeyword(datatable)}{Quotes};"; usingBlock.Statements.Add($"sqlCommand.CommandText = {sqlString} "); usingBlock.Statements.Add($"{NewLine}sqlCommand.Parameters.AddWithValue({$"{Quotes}@Keyword{Quotes}"}, keyword);"); usingBlock.Statements.Add($"sqlCommand.Parameters.AddWithValue({Quotes}@Start{Quotes}, start);"); usingBlock.Statements.Add($"sqlCommand.Parameters.AddWithValue({Quotes}@End{Quotes}, end);"); usingBlock.Statements.Add($"return ToList(sqlCommand);"); this.Statements.Add(usingBlock.ToString()); }
private void ConstructBody() { VBBlock usingBlock = new VBBlock(VBBlockStatement.Using, "Using sqlCommand As New SqlCommand()"); string sqlString = $"${Quotes}{SqlSelectBuilder.CreateSelectByKeyword(datatable)}{Quotes}"; usingBlock.Statements.Add($"sqlCommand.CommandText = {sqlString} "); usingBlock.Statements.Add($"{NewLine}sqlCommand.Parameters.AddWithValue({$"{Quotes}@Keyword{Quotes}"}, keyword)"); usingBlock.Statements.Add($"sqlCommand.Parameters.AddWithValue({Quotes}@Start{Quotes}, start)"); usingBlock.Statements.Add($"sqlCommand.Parameters.AddWithValue({Quotes}@End{Quotes}, _end)"); usingBlock.Statements.Add($"Return ToList(sqlCommand)"); this.Statements.Add(usingBlock.ToString()); }