Exemplo n.º 1
0
        private void ConstructBody()
        {
            VBBlock usingBlock     = new VBBlock(VBBlockStatement.Using, "Using sqlCommand As New SqlCommand()");
            string  parameterName  = $"{Quotes}@{datacolumn.ColumnName.Replace(" ","")}{Quotes}";
            string  parameterValue = ProperVarName.Get(datacolumn.ColumnName.ToLower());
            string  columnName     = datacolumn.ColumnName.Contains(" ") ? $"[{datacolumn.ColumnName}]" : datacolumn.ColumnName;
            string  sqlString      = $"{Quotes}{SqlSelectBuilder.CreateSelectAllWhere(datatable, $"{columnName} = @{datacolumn.ColumnName.Replace(" ", "")}")}{Quotes}";

            usingBlock.Statements.Add($"sqlCommand.CommandText = {sqlString}");
            usingBlock.Statements.Add($"sqlCommand.Parameters.AddWithValue({parameterName}, {parameterValue})");
            usingBlock.Statements.Add($"Return ToList(sqlCommand)");
            this.Statements.Add(usingBlock.ToString());
        }