public static string GetRemappedLinqSql(LinqSQLFromClause tableInfo, string whereClause, LinqSQLFromClauseCollection fromLinkList, ObjectTypeConstants type) { if (type == ObjectTypeConstants.Table) { switch (tableInfo.TableName) { case "ConfigSetting": return(Gravitybox.gFileSystem.EFDAL.Entity.ConfigSetting.GetRemappedLinqSql(whereClause, tableInfo.Alias, fromLinkList)); case "Container": return(Gravitybox.gFileSystem.EFDAL.Entity.Container.GetRemappedLinqSql(whereClause, tableInfo.Alias, fromLinkList)); case "FileStash": return(Gravitybox.gFileSystem.EFDAL.Entity.FileStash.GetRemappedLinqSql(whereClause, tableInfo.Alias, fromLinkList)); case "Tenant": return(Gravitybox.gFileSystem.EFDAL.Entity.Tenant.GetRemappedLinqSql(whereClause, tableInfo.Alias, fromLinkList)); } } if (type == ObjectTypeConstants.View) { } if (type == ObjectTypeConstants.StoredProcedure) { } throw new Exception("Table not found '" + tableInfo.TableName + "'."); }
private void RemapParentChild() { //Include all base tables LinqSQLFromClauseCollection childTables = new LinqSQLFromClauseCollection(); foreach (var fromClause in _fromLinkList) { //Do all field replacements if (_type == ObjectTypeConstants.Table) { if (fromClause.TableName == "ConfigSetting") { childTables.Add(fromClause); } if (fromClause.TableName == "Container") { childTables.Add(fromClause); } if (fromClause.TableName == "FileStash") { childTables.Add(fromClause); } if (fromClause.TableName == "Tenant") { childTables.Add(fromClause); } } if (_type == ObjectTypeConstants.View) { } } _fromLinkList.Clear(); _fromLinkList.AddRange(childTables); //Process the FROM clause _fromLinkList.RemapFromClause(); //Now map the columns to the proper tables foreach (var field in this.FieldList) { LinqSQLFromClause clause = _fromLinkList.FirstOrDefault(x => x.Alias == field.Table); string realTable = string.Empty; if (_type == ObjectTypeConstants.Table) { if (clause.TableName == "ConfigSetting") { realTable = Gravitybox.gFileSystem.EFDAL.Entity.ConfigSetting.GetTableFromFieldAliasSqlMapping(field.Alias); } else if (clause.TableName == "Container") { realTable = Gravitybox.gFileSystem.EFDAL.Entity.Container.GetTableFromFieldAliasSqlMapping(field.Alias); } else if (clause.TableName == "FileStash") { realTable = Gravitybox.gFileSystem.EFDAL.Entity.FileStash.GetTableFromFieldAliasSqlMapping(field.Alias); } else if (clause.TableName == "Tenant") { realTable = Gravitybox.gFileSystem.EFDAL.Entity.Tenant.GetTableFromFieldAliasSqlMapping(field.Alias); } } var sqlFromClause = _fromLinkList.GetByTable(realTable); field.Table = sqlFromClause.Alias; } //Calculate the WHERE clause if (!string.IsNullOrEmpty(_whereClause)) { foreach (var fromClause in _fromLinkList) { //Only process table that were original and not inserted above if (fromClause.AnchorAlias == string.Empty) { _whereClause = GetRemappedLinqSql(fromClause, _whereClause, _fromLinkList, _type); } } } }