Exemplo n.º 1
0
        public SqlExp <T2> JoinSubQuery <T2, TKey>(Action <SqlExp <T2> > action, Expression <Func <T, T2, bool> > expression, JoinType joinType = JoinType.Join)
        {
            var joinQuery = new SqlExp <T2>(this._adapter);

            action?.Invoke(joinQuery);
            _resolver.JoinSubQuery(joinQuery, expression, joinType);

            this._childSqlExps.Add(joinQuery);

            return(joinQuery);
        }
Exemplo n.º 2
0
        public SqlExp <T2> InnerJoin <T2, TKey>(Action <SqlExp <T2> > joinQuery,
                                                Expression <Func <T, TKey> > primaryKeySelector,
                                                Expression <Func <T2, TKey> > foreignKeySelector,
                                                params Expression <Func <T2, object> >[] selections)
        {
            var query = new SqlExp <T2>(_builder, _resolver);

            joinQuery?.Invoke(query);

            query.Select(selections);

            _resolver.Join <T, T2, TKey>(primaryKeySelector, foreignKeySelector, JoinType.InnerJoin);
            return(query);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public SqlExp <T2> SubQuery <T2>(SqlExp <T2> subQuery)
        {
            var aliasTname = $"query_" + DateTime.Now.Ticks;

            JoinSubAliasTableName = aliasTname;

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

            _resolver.SubQuery <T2>(subQuery);

            // query.Select(selections);

            return(subQuery);
        }
Exemplo n.º 5
0
        public SqlExp <T2> JoinSubQuery <T2, TKey>(Action <SqlExp <T2> > joinQuery,
                                                   Expression <Func <T, TKey> > primaryKeySelector,
                                                   Expression <Func <T2, TKey> > foreignKeySelector, JoinType joinType = JoinType.Join,
                                                   params Expression <Func <T2, object> >[] selections)
        {
            var query = new SqlExp <T2>(_adapter);

            joinQuery?.Invoke(query);


            _resolver.JoinSubQuery <T, T2, TKey>(query, primaryKeySelector, foreignKeySelector, joinType);

            // query.Select(selections);

            this._childSqlExps.Add(query);
            this.SelectSubQuery(query, selections);



            return(query);
        }
Exemplo n.º 6
0
 public SqlExp <T> CountSubQuery <TSub>(SqlExp <TSub> subExp, string aliasName = "count")
 {
     _resolver.SelectWithFunction <T>(null, SelectFunction.COUNT, aliasName, subExp.JoinSubAliasTableName);
     return(this);
 }
Exemplo n.º 7
0
 public SqlExp <T> CountSubQuery <TSub>(SqlExp <TSub> subExp, Expression <Func <T, object> > expression)
 {
     _resolver.SelectWithFunctionSubQuery <T, TSub>(expression, SelectFunction.COUNT, null, subExp.JoinSubAliasTableName);
     return(this);
 }
Exemplo n.º 8
0
        //public SqlExp<T> Count<TSub>(SqlExpBase subExp,Expression<Func<T, object>> expression, Expression<Func<TSub, object>> aliasProp)
        //{
        //    _resolver.SelectWithFunctionSubQuery<T, TSub>(expression, SelectFunction.COUNT, aliasProp,subExp.JoinSubAliasTableName);
        //    return this;
        //}
        //public SqlExp<T> Count(string aliasName = "count")
        //{
        //    _resolver.SelectWithFunction<T>(null, SelectFunction.COUNT, aliasName);
        //    return this;
        //}
        //public SqlExp<T> Count<TResult>(SqlExp<TResult> subExp,string aliasName = "count")
        //{

        //    _resolver.SelectWithFunction<T>(null, SelectFunction.COUNT, aliasName,subExp.JoinSubAliasTableName);
        //    return this;
        //}

        public SqlExp <T> CountSubQuery <TResult>(SqlExp <T> subExp, Expression <Func <T, object> > expression, Expression <Func <TResult, object> > aliasProp)
        {
            _resolver.SelectWithFunctionSubQuery <T, TResult>(expression, SelectFunction.COUNT, aliasProp, subExp.JoinSubAliasTableName);
            return(this);
        }