コード例 #1
0
        public string GetSchemaName()
        {
            var schemaName = _sqlAdapter.GetSchemaName(_schemaName);
            var schemaNameWithConvention = $"{schemaName}";

            return(schemaNameWithConvention);
        }
コード例 #2
0
        public void AddJoinByType(string tableSchemaName, string originalTableName, string joinTableName, string leftField, string rightField, JoinType joinType, string tableAlias)
        {
            var existsTableNameRealOverride = !String.IsNullOrEmpty(_tableNameRealOverride);
            var tableNameSource             = existsTableNameRealOverride ? _tableNameRealOverride : originalTableName;
            var tableSchemaNameToUse        = _sqlAdapter.GetSchemaName(tableSchemaName);
            var tableNameToJoin             = _sqlAdapter.GetTableName(joinTableName);
            var columnJoinLeft     = _sqlAdapter.GetColumnName(tableNameSource, leftField);
            var existsTableAlias   = !String.IsNullOrEmpty(tableAlias);
            var joinTableNameToUse = existsTableAlias ? tableAlias : joinTableName;
            var columnJoinRight    = _sqlAdapter.GetColumnName(joinTableNameToUse, rightField);
            var typeJoinNormalized = joinType.ToString().ToUpper();
            var charToUse          = _formatting == SqlBuilderFormatting.Indented ? "\n" : "";
            var joinClause         = new StringBuilder($"{charToUse}{typeJoinNormalized} JOIN {tableSchemaNameToUse}.{tableNameToJoin} ");

            if (existsTableAlias)
            {
                joinClause.Append($"AS {tableAlias} ");
            }

            joinClause.Append($"ON ({columnJoinLeft} = {columnJoinRight}) ");

            _sqlQueryBuilderExtension.AddJoinExpression(joinClause.ToString());
        }