Exemple #1
0
        public void BuildJoinTable(SqlJoinType type, Type tableType, string aliasName)
        {
            string tableName  = this.GetTableName(tableType, aliasName);
            string joinString = string.Format("{0} JOIN {1} ON", type.ToString(), tableName);

            _joins.Add(joinString);
        }
Exemple #2
0
        public void JoinMergeHintTest(
            [IncludeDataSources(true, TestProvName.AllSqlServer)] string context,
            [Values(SqlJoinType.Inner, SqlJoinType.Left, SqlJoinType.Full)] SqlJoinType joinType)
        {
            using var db = GetDataContext(context);

            var q = db.Child.Join(db.Parent.AsSqlServer().JoinMergeHint(), joinType, (c, p) => c.ParentID == p.ParentID, (c, p) => p);

            _ = q.ToList();

            Assert.That(LastQuery, Contains.Substring($"{joinType.ToString().ToUpper()} MERGE JOIN"));
        }
Exemple #3
0
        public void JoinHintMethodTest(
            [IncludeDataSources(true, TestProvName.AllSqlServer)] string context,
            [Values(SqlServerHints.Join.Loop, SqlServerHints.Join.Hash, SqlServerHints.Join.Merge)] string hint,
            [Values(SqlJoinType.Left, SqlJoinType.Full)] SqlJoinType joinType)
        {
            using var db = GetDataContext(context);

            var q = db.Child.Join(db.Parent.JoinHint(hint), joinType, (c, p) => c.ParentID == p.ParentID, (c, p) => p);

            _ = q.ToList();

            Assert.That(LastQuery, Contains.Substring($"{joinType.ToString().ToUpper()} {hint} JOIN"));
        }
Exemple #4
0
        public virtual void RenderJoin(ISqlTable leftTable, SqlJoinType joinType, ISqlTable rightTable, IEnumerable <ISqlFilter> conditions, SqlBuildArguments args)
        {
            this.WriteSpace();
            this.Write(joinType.ToString().ToUpper());
            this.WriteSpace();
            this.Write("JOIN");
            this.WriteSpace();

            //TODO: This is causing joined tables to render their conditions here, which is not right.
            rightTable.Render(this, args);

            if (joinType != SqlJoinType.Cross)
            {
                this.WriteSpace();
                this.Write(SqlConstants.ON);
                this.WriteSpace();
                this.RenderAll <ISqlFilter>(conditions, args, string.Concat(SqlConstants.SPACE, ConvertSqlLogicToString(SqlLogic.And), SqlConstants.SPACE));
            }
            this.WriteNewLine();
        }