private PsqlGeneratingExpressionVisitor(PsqlGeneratingQueryModelVisitor queryModelVisitor, ExpressionVisitorOptions options = null)
        {
            _psqlExpressionBuilder = new StringBuilder();
            _queryModelVisitor     = queryModelVisitor;

            _visitorTriggeredByMemberVisitor = false;
            _readingConditionalStatement     = false;
            _renamingColumns = false;

            _table           = queryModelVisitor._table;
            _tableDefinition = _table.TableDefinition;
            _options         = options ?? new ExpressionVisitorOptions();
        }
        public override void VisitWhereClause(WhereClause whereClause, QueryModel queryModel, int index)
        {
            var wherePredicateType = whereClause.Predicate.GetType();

            if (whereClause.Predicate is SubQueryExpression subQuery)
            {
                var t = subQuery.QueryModel.BodyClauses;
                if (subQuery.QueryModel.SelectClause.Selector is QuerySourceReferenceExpression _sExpression)
                {
                    var z  = _sExpression.ReferencedQuerySource.ToString();
                    var z1 = z.Split(' ').LastOrDefault();
                    var z2 = z1?.Split(".".ToCharArray(), 2)[1];

                    _queryParts.AddWherePart(z2);
                    foreach (var queryModelBodyClause in subQuery.QueryModel.BodyClauses)
                    {
                        if (queryModelBodyClause is WhereClause where)
                        {
                            var opts = new ExpressionVisitorOptions();
                            opts.TableName = z2;
                            var expr = PsqlGeneratingExpressionVisitor.GetPsqlExpression(where.Predicate, this, opts); GetPsqlExpression(where.Predicate);
                            _queryParts.AddWherePart(expr);
                        }
                        //var props = queryModelBodyClause.ToString().Split('.').Skip(1).ToList();
                    }
                }


                _queryParts.AddWherePart(GetPsqlExpression(whereClause.Predicate));
            }
            else
            {
                _queryParts.AddWherePart(GetPsqlExpression(whereClause.Predicate));
            }
            //_queryParts.AddWherePart(GetPsqlExpression(whereClause.Predicate));
            base.VisitWhereClause(whereClause, queryModel, index);
        }
        public static string GetPsqlExpression(Expression linqExpression, PsqlGeneratingQueryModelVisitor queryModelVisitor, ExpressionVisitorOptions options)
        {
            var visitor = new PsqlGeneratingExpressionVisitor(queryModelVisitor, options);

            visitor.Visit(linqExpression);
            return(visitor.GetPsqlExpression());
        }