Ejemplo n.º 1
0
        public SqlExp <T2> SubQuery <T2>(SqlExp <T2> subQuery)
        {
            var aliasTname = $"q_" + EnvHelper.GetRandomString(6, true, true, false); //$"query_" + DateTime.Now.Ticks;

            JoinSubAliasTableName = aliasTname;

            subQuery.JoinSubAliasTableName = aliasTname;
            this._childSqlExps.Add(subQuery);

            _resolver.SubQuery <T2>(subQuery);

            // query.Select(selections);

            return(subQuery);
        }
        public void JoinSub(SqlExpBase sqlExp, string originalTableName, string joinTableName, string leftField, string rightField, JoinType joinType)
        {
            var joinTypeStr = GetJoinType(joinType);

            //var aliasTname = $"join_" + DateTime.Now.Ticks;
            var aliasTname = $"j_" + EnvHelper.GetRandomString(6, true, true, false);// $"join_" + DateTime.Now.Ticks;

            sqlExp.JoinSubAliasTableName = aliasTname;

            JoinSubAliasTableName = aliasTname;
            var subQueryStr = sqlExp.SqlString;

            var joinString = string.Format("{3} ({0}) {4} ON {1} = {4}.{2}",
                                           subQueryStr,
                                           _adapter.Field(originalTableName, leftField),
                                           _adapter.Field(rightField), joinTypeStr, aliasTname);

            _tableNames.Add(joinTableName);
            _joinExpressions.Add(joinString);
            _splitColumns.Add(rightField);
        }