Example #1
0
        public Q WhereExists(Query query)
        {
            if (!query.HasComponent("from"))
            {
                throw new ArgumentException(@"""FromClause"" cannot be empty if used inside of a ""WhereExists"" condition");
            }

            return(AddComponent("where", new ExistsCondition <Query>
            {
                Query = query.ClearComponent("select").SelectRaw("1").Limit(1).SetEngineScope(EngineScope),
                IsNot = getNot(),
                IsOr = getOr(),
            }));
        }
        public Q WhereExists(Query query)
        {
            if (!query.HasComponent("from"))
            {
                throw new ArgumentException("'FromClause' cannot be empty if used inside a 'WhereExists' condition");
            }

            // remove unneeded components
            query = query.Clone().ClearComponent("select")
                    .SelectRaw("1");

            return(AddComponent("where", new ExistsCondition
            {
                Query = query,
                IsNot = GetNot(),
                IsOr = GetOr(),
            }));
        }
Example #3
0
        public Query HavingExists(Query query)
        {
            if (!query.HasComponent("from"))
            {
                throw new ArgumentException("'FromClause' cannot be empty if used inside a 'HavingExists' condition");
            }

            // simplify the query as much as possible
            query = query.Clone().ClearComponent("select")
                    .SelectRaw("1")
                    .Limit(1);

            return(AddComponent("having", new ExistsCondition
            {
                Query = query,
                IsNot = GetNot(),
                IsOr = GetOr(),
            }));
        }