void SetSubIndex <T>(ExpressionParserOld <T> parser) { if (_subIndex == null) { _subIndex = Field.Select(parser); for (var i = 0; i < _subIndex.Length; i++) { var idx = _subIndex[i]; var f = QuerySource.BaseQuery.GetField(idx.Field); if (f != null && f != idx.Field) { var idxs = f.Select(parser); if (idxs.Length == 1) { _subIndex[i] = idxs[0]; } } } if (QuerySource.SubSql.HasUnion) { var sub = QuerySource.BaseQuery; var idx = sub.Fields.IndexOf(Field); var mi = sub.GetMember(Field); foreach (var union in QuerySource.Unions) { if (mi != null) { var f = union.GetField(mi, _ => _ is QuerySource); if (f != null) { f.Select(parser); continue; } if (union is QuerySource.Expr) { union.SqlQuery.Select.Add(new SqlValue(null)); continue; } } union.Fields[idx].Select(parser); } } } }
//ISqlExpression _sqlExpression; public override FieldIndex[] Select <T>(ExpressionParserOld <T> parser) { if (_index == null) { var idx = _queryField.Select(parser); var expr = idx[0].Field.GetExpressions(parser); _index = new[] { new FieldIndex { Index = _querySource.SqlQuery.Select.Add(expr[0]), Field = this } }; } return(_index); }
void SetSubIndex <T>(ExpressionParser <T> parser) { if (_subIndex == null) { _subIndex = Field.Select(parser); if (QuerySource.SubSql.HasUnion) { var sub = QuerySource.BaseQuery; var idx = sub.Fields.IndexOf(Field); var mi = sub.GetMember(Field); foreach (var union in QuerySource.Unions) { if (mi != null) { var f = union.GetField(mi); if (f != null) { f.Select(parser); continue; } if (union is QuerySource.Expr) { union.SqlQuery.Select.Add(new SqlValue(null)); continue; } } union.Fields[idx].Select(parser); } } } }