예제 #1
0
 public SqlExpression <T> LeftJoin <Source, Target>(Expression <Func <Source, Target, bool> > joinExpr, JoinFormatDelegate joinFormat)
 {
     return(InternalJoin("LEFT JOIN", joinExpr, joinFormat));
 }
예제 #2
0
        public SqlExpression <T> RightJoin <Target>(Expression <Func <T, Target, bool> > joinExpr, JoinFormatDelegate joinFormat)
        {
            if (joinFormat == null)
            {
                throw new ArgumentNullException(nameof(joinFormat));
            }

            return(InternalJoin("RIGHT JOIN", joinExpr, joinFormat));
        }
예제 #3
0
        private SqlExpression <T> InternalJoin(string joinType, Expression joinExpr, ModelDefinition sourceDef, ModelDefinition targetDef, JoinFormatDelegate joinFormat = null)
        {
            PrefixFieldWithTableName = true;

            //Changes how Sql Expressions are generated.
            useFieldName = true;
            sep          = " ";

            if (!tableDefs.Contains(sourceDef))
            {
                tableDefs.Add(sourceDef);
            }
            if (!tableDefs.Contains(targetDef))
            {
                tableDefs.Add(targetDef);
            }

            var isCrossJoin = "CROSS JOIN".Equals(joinType);

            var sqlExpr = joinExpr != null
                ? InternalCreateSqlFromExpression(joinExpr, isCrossJoin)
                : InternalCreateSqlFromDefinitions(sourceDef, targetDef, isCrossJoin);

            var joinDef = tableDefs.Contains(targetDef) && !tableDefs.Contains(sourceDef)
                ? sourceDef
                : targetDef;

            FromExpression += joinFormat != null
                ? $" {joinType} {joinFormat(DialectProvider, joinDef, sqlExpr)}"
                : $" {joinType} {SqlTable(joinDef)} {sqlExpr}";

            return(this);
        }
예제 #4
0
        protected SqlExpression <T> InternalJoin <Source, Target>(string joinType, Expression <Func <Source, Target, bool> > joinExpr, JoinFormatDelegate joinFormat = null)
        {
            var sourceDef = typeof(Source).GetModelDefinition();
            var targetDef = typeof(Target).GetModelDefinition();

            return(InternalJoin(joinType, joinExpr, sourceDef, targetDef, joinFormat));
        }
 public SqlExpression <T> LeftJoin <Target>(Expression <Func <T, Target, bool> > joinExpr, JoinFormatDelegate joinFormat) =>
 InternalJoin("LEFT JOIN", joinExpr, joinFormat ?? throw new ArgumentNullException(nameof(joinFormat)));
 public SqlExpression <T> Join <Source, Target>(Expression <Func <Source, Target, bool> > joinExpr, JoinFormatDelegate joinFormat) =>
 InternalJoin("INNER JOIN", joinExpr, joinFormat);
 protected SqlExpression <T> InternalJoin <Source, Target>(string joinType, Expression <Func <Source, Target, bool> > joinExpr, JoinFormatDelegate joinFormat) =>
 InternalJoin(joinType, joinExpr, joinFormat != null ? new TableOptions {
     JoinFormat = joinFormat
 } : null);