/// <summary> /// 关联表 /// </summary> /// <param name="from"></param> /// <param name="sourceTable"></param> /// <param name="targetTable"></param> /// <returns></returns> private KeyWordFromItem InnerTable(KeyWordFromItem from, AliasTableMapping sourceTable) { KeyWordFromItem inner = from; string sTableName = sourceTable.TableInfo.GetAliasName(); foreach (KeyValuePair <string, AliasTableMapping> tablePair in sourceTable.ChildTables) { AliasTableMapping tTable = tablePair.Value; string tTableName = tTable.TableInfo.GetAliasName(); EntityMappingInfo minfo = tTable.MappingInfo; BQLCondition fhandle = null; //if (minfo.IsPrimary) //{ fhandle = BQL.Tables[sTableName][minfo.SourceProperty.ParamName] == BQL.Tables[tTableName][minfo.TargetProperty.ParamName]; //} //else //{ // fhandle = BQLDbBase.BQL.Tables[sTableName][minfo.SourceProperty.ParamName] == BQLDbBase.BQL.Tables[tTableName][minfo.PrimaryKey]; //} inner = inner.LeftJoin(tablePair.Value.TableInfo, fhandle); if (tTable.ChildTables.Count > 0) { inner = InnerTable(inner, tTable); } } return(inner); }
/// <summary> /// 给表查询加上关联表 /// </summary> /// <param name="from"></param> /// <returns></returns> public KeyWordFromItem ToInnerTable(KeyWordFromItem from, KeyWordInfomation info) { KeyWordFromItem inner = InnerTable(from, _primaryTable); return(inner); }