private List <string> GetSubItems() { var isubList = this.allMethods.Select(exp => { var methodName = exp.Method.Name; var items = SubTools.SubItems(this.context); var item = items.First(s => s.Name == methodName); if (item is SubWhere && hasWhere == false) { hasWhere = true; } else if (item is SubWhere) { item = items.First(s => s is SubAnd); } if (item is SubWhereIF && hasWhere == false) { hasWhere = true; } else if (item is SubWhereIF) { item = items.First(s => s is SubAndIF); } item.Context = this.context; item.Expression = exp; return(item); }).ToList(); isubList.Insert(0, new SubBegin()); if (isubList.Any(it => it is SubSelect)) { isubList.Add(new SubTop() { Context = this.context }); } if (isubList.Any(it => it is SubAny || it is SubNotAny)) { isubList.Add(new SubLeftBracket()); isubList.Add(new SubRightBracket()); isubList.Add(new SubSelectDefault()); } isubList = isubList.OrderBy(it => it.Sort).ToList(); var isHasWhere = isubList.Where(it => it is SubWhere).Any(); List <string> result = isubList.Select(it => { it.HasWhere = isHasWhere; return(it.GetValue(it.Expression)); }).ToList(); return(result); }
private List <string> GetSubItems() { var isSubSubQuery = this.allMethods.Select(it => it.ToString()).Any(it => Regex.Matches(it, "Subquery").Count > 1); var isubList = this.allMethods.Select(exp => { if (isSubSubQuery) { this.context.JoinIndex = 1; this.context.SubQueryIndex = 0; } var methodName = exp.Method.Name; var items = SubTools.SubItems(this.context); var item = items.First(s => s.Name == methodName); if (item is SubWhere && hasWhere == false) { hasWhere = true; } else if (item is SubWhere) { item = items.First(s => s is SubAnd); } if (item is SubWhereIF && hasWhere == false) { hasWhere = true; } else if (item is SubWhereIF) { item = items.First(s => s is SubAndIF); } item.Context = this.context; item.Expression = exp; return(item); }).ToList(); isubList.Insert(0, new SubBegin()); if (isubList.Any(it => it is SubSelect)) { isubList.Add(new SubTop() { Context = this.context }); } if (isubList.Any(it => it is SubAny || it is SubNotAny)) { isubList.Add(new SubLeftBracket()); isubList.Add(new SubRightBracket()); isubList.Add(new SubSelectDefault()); } isubList = isubList.OrderBy(it => it.Sort).ToList(); var isHasWhere = isubList.Where(it => it is SubWhere).Any(); var isJoin = isubList.Any(it => it is SubInnerJoin || it is SubLeftJoin); if (isJoin) { this.context.JoinIndex++; } List <string> result = isubList.Select(it => { it.HasWhere = isHasWhere; return(it.GetValue(it.Expression)); }).ToList(); this.context.JoinIndex = 0; return(result); }