public void Create(SQL _Sql, LambdaExpression _LambdaExpression, EJoinType _EJoinType, Analysis analysis) { if (_LambdaExpression.Body is BinaryExpression) { var body = (_LambdaExpression.Body as BinaryExpression); var _Parameters = _LambdaExpression.Parameters; var _Parameter = _Parameters[_Parameters.Count - 1]; var _Alias = DbSettings.KeywordHandle(_Parameter.Name); var _TabName = DbSettings.KeywordHandle(_Parameter.Type.Name); _Sql.Code_Join.AppendFormat(" {0} {1} AS {2} ON ", _EJoinType.ToString().Replace("_", " "), _TabName, _Alias); var _New_Sql = new SQL(); _New_Sql.Parameter = _Sql.Parameter; analysis.CreateWhere(_LambdaExpression, _New_Sql); _Sql.Code_Join.Append(_New_Sql.Code_Where); _Sql.Parameter = _New_Sql.Parameter; _Sql.Alias[_Alias] = _TabName; } }
public JoinTable(IQueryTable joinQueryTable, WhereClip joinWhere, EJoinType joinType, params ExpressionClip[] queryCulumns) { this.JoinQueryTable = joinQueryTable; this.JoinWhere = joinWhere; this.JoinType = joinType; this.QueryCulumns = queryCulumns; }
public void Create(SQL _Sql, LambdaExpression _LambdaExpression, EJoinType _EJoinType, Analysis analysis) { PropertyInfo propertyInfo = null; foreach (var item in _LambdaExpression.Parameters) { var _TypeInfo = item.Type as TypeInfo; propertyInfo = _TypeInfo.GetProperties().OrderByDescending(w => w.Name).ToList()[0]; } var _Alias = DbSettings.KeywordHandle(propertyInfo.Name); var _TabName = DbSettings.KeywordHandle(propertyInfo.PropertyType.Name); _Sql.Code_Join.AppendFormat(" {0} {1} AS {2} ON ", _EJoinType.ToString().Replace("_", " "), _TabName, _Alias); var _New_Sql = new SQL(); _New_Sql.Parameter = _Sql.Parameter; analysis.CreateWhere(_LambdaExpression, _New_Sql); _Sql.Code_Join.Append(_New_Sql.Code_Where); _Sql.Parameter = _New_Sql.Parameter; _Sql.Alias[_Alias] = _TabName; if (!_Sql.TableNames.Contains(propertyInfo.PropertyType.Name)) { _Sql.TableNames.Add(propertyInfo.PropertyType.Name); } }
public JOIN(EJoinType joinType, Expression table1, Expression table2, Expression joinExpression) { this.joinType = joinType; this.table1 = table1; this.table2 = table2; this.joinExpression = joinExpression; this.joinType = joinType; }
public JoinedTable(EJoinType joinType, ITableSource table, bool isWeak, ISearchCondition searchCondition) { JoinType = joinType; Table = table; IsWeak = isWeak; Condition = searchCondition; CanConvertApply = true; }
internal Join(EJoinType joinType, ISqlTableSource table, string alias, bool isWeak, IReadOnlyList <IJoin> joins) { JoinedTable = new JoinedTable(joinType, table, alias, isWeak); if (joins != null && joins.Count > 0) { for (var index = 0; index < joins.Count; index++) { JoinedTable.Table.Joins.AddLast(joins[index].JoinedTable); } } }
/// <summary> /// 添加关联查询 /// </summary> /// <param name="queryTable">关联表</param> /// <param name="joinWhere">关联条件</param> /// <param name="joinType">关联类型</param> /// <returns>ModalAdapter</returns> public ModalAdapter <T> Join(IQueryTable queryTable, WhereClip joinWhere, EJoinType joinType) { switch (joinType) { case EJoinType.Join: this._SelectSection.Join(queryTable, joinWhere); break; case EJoinType.LeftJoin: this._SelectSection.LeftJoin(queryTable, joinWhere); break; case EJoinType.RightJoin: this._SelectSection.RightJoin(queryTable, joinWhere); break; } this.JoinTables.Add(new JoinTable(queryTable, joinWhere, joinType)); return(this); }
public abstract IJoin <T, TJoin> Join <TJoin>(Expression <Func <HzyTuple <T, TJoin>, bool> > ON, EJoinType _EJoinType = EJoinType.LEFT_JOIN);
public JoinedTable(EJoinType joinType, ISqlTableSource table, string alias, bool isWeak) : this(joinType, new TableSource(table, alias), isWeak) { }
public JoinedTable(EJoinType joinType, ITableSource table, bool isWeak) : this(joinType, table, isWeak, new SearchCondition()) { }
/// <summary> /// 创建 Join 对象 /// </summary> /// <param name="_LambdaExpression"></param> /// <param name="_Sql"></param> /// <param name="_EJoinType"></param> public void CreateJoin(LambdaExpression _LambdaExpression, SQL _Sql, EJoinType _EJoinType) { new JoinAnalysis().Create(_Sql, _LambdaExpression, _EJoinType, this); }
public abstract IJoin <T1, T2, TJoin> Join <TJoin>(Expression <Func <T1, T2, TJoin, bool> > ON, EJoinType _EJoinType = EJoinType.LEFT_JOIN);
public override IJoin <T, TJoin> Join <TJoin>(Expression <Func <HzyTuple <T, TJoin>, bool> > ON, EJoinType _EJoinType = EJoinType.LEFT_JOIN) { if (ON == null) { throw new DbFrameException(" Join 连接对象不能为 NULL !"); } this.analysis.CreateJoin(ON, this.SqlCode, _EJoinType); return(new JoinAchieve <T, TJoin>(this.SqlCode, this.Ado, this.analysis)); }
public override IJoin <T, TJoin> Join <TJoin>(Expression <Func <T, TJoin, bool> > ON, EJoinType _EJoinType = EJoinType.LEFT_JOIN) { if (ON == null) { throw new DbFrameException(" Join 连接对象不能为 NULL !"); } //给表设置别名 var _Param = ON.Parameters[0]; var _Alias = DbSettings.KeywordHandle(_Param.Name); this.SqlCode.Code_FromTab.Append(" AS " + _Alias); this.SqlCode.Alias[_Alias] = _Param.Type.Name; this.SqlCode.IsAlias = true; this.analysis.CreateJoin(ON, this.SqlCode, _EJoinType); return(new JoinAchieve <T, TJoin>(this.SqlCode, this.Ado, this.analysis)); }
public JoinTable(IQueryTable joinQueryTable, string aliasName, WhereClip joinWhere, EJoinType joinType, params ExpressionClip[] queryCulumns) : this(joinQueryTable, joinWhere, joinType, queryCulumns) { this.AliasName = aliasName; }
/// <summary> /// 添加关联查询 /// </summary> /// <param name="queryTable">关联表</param> /// <param name="joinTableAliasName">关联表别名</param> /// <param name="joinWhere">关联条件</param> /// <param name="joinType">关联类型</param> /// <returns>ModalAdapter</returns> public SearchHelper Join(IQueryTable queryTable, string joinTableAliasName, WhereClip joinWhere, EJoinType joinType) { switch (joinType) { case EJoinType.Join: this._SelectSection.Join(queryTable, joinTableAliasName, joinWhere); break; case EJoinType.LeftJoin: this._SelectSection.LeftJoin(queryTable, joinTableAliasName, joinWhere); break; case EJoinType.RightJoin: this._SelectSection.RightJoin(queryTable, joinTableAliasName, joinWhere); break; } this.JoinTables.Add(new JoinTable(queryTable, joinTableAliasName, joinWhere, joinType)); return(this); }
public static JoinTable New(string table, EJoinType joinType) { return(new JoinTable(table, joinType)); }
public JoinTable(string table, EJoinType joinType) { this.Table = table; this.JoinType = joinType; }