Esempio n. 1
0
        public string GetColumnsToAppendSelectFromTableType(string tableName, Type?typeTable = null)
        {
            var charsSplitColumns        = GetCharsSplitColumns();
            var tableNameWithConvention  = _sqlAdapter.GetTableName(tableName);
            var typeTableToUse           = typeTable != null ? typeTable : _typeTable;
            var propertiesFromClassTable = typeTableToUse.GetProperties();
            var columnsToAppend          = propertiesFromClassTable.Select(c =>
            {
                var columnName = SqlBuilderFluentHelper.GetColumnName(c);
                var columnNameWithConvention = _sqlAdapter.GetColumnName(tableName, columnName);
                var hasColumnAttribute       = SqlBuilderFluentHelper.HasColumnAttribute(c);

                if (hasColumnAttribute)
                {
                    columnNameWithConvention += $" AS {c.Name}";
                }

                return(columnNameWithConvention);
            });
            var columnsToAppendSelect = String.Join(charsSplitColumns, columnsToAppend);

            return(columnsToAppendSelect);
        }
Esempio n. 2
0
        public void AddClauseByOperation(string tableName, string columnName, string operation, object columnValue, string tableAlias, TargetClauseType targetClauseType, SelectFunction?selectFunction)
        {
            var tableNameToUse            = _sqlQueryBuilderExtension.GetTableNameUseConsideringAlias(tableName, tableAlias);
            var parameterNameByColumnName = _sqlQueryBuilderExtension.GetParameterNameByColumnName(columnName);
            var columnNameWithConvention  = _sqlAdapter.GetColumnName(tableNameToUse, columnName);
            var parameterFormated         = _sqlAdapter.GetParameterFormated(parameterNameByColumnName);
            var clauseInput = new ClauseInput(columnNameWithConvention, operation, parameterFormated, ClauseInputType.ByOperation);

            _sqlQueryBuilderExtension.AddClauseOperation(clauseInput, targetClauseType, selectFunction);
            _sqlQueryBuilderExtension.AddParameter(parameterNameByColumnName, columnValue);
        }