Beispiel #1
0
        string ToNestedSubQuerySql(SqlConversionContext context, string[] parts)
        {
            var proc = new NestedCriteriaProcessor(context.Type, parts);

            var subCriterion = new Criterion(proc.Property.Name, FilterFunction, Value);

            var r = new StringBuilder();

            foreach (var sub in proc.Queries)
            {
                r.AppendLine("EXISTS (");
                r.AppendLine(sub.ToString());
                r.AppendLine("AND ");
            }

            var newContext = new SqlConversionContext
            {
                Alias    = context.ToSafeId(proc.TableAlias),
                Query    = context.Query,
                ToSafeId = context.ToSafeId,
                Type     = proc.Property.PropertyType
            };

            r.Append(subCriterion.ToSqlOn(newContext));

            foreach (var sub in proc.Queries)
            {
                r.Append(")");
            }

            return(r.ToString());
        }
Beispiel #2
0
        string ToNestedSubQuerySql(SqlConversionContext context, string[] parts)
        {
            if (context.Query.AliasPrefix.HasValue())
            {
                throw new NotSupportedException("Conditions on associations is not supported when query is a sub query.");
            }

            var proc = new NestedCriteriaProcessor(context.Type, parts);

            var subCriterion = new Criterion(proc.Property.Name, FilterFunction, Value);

            var r = new StringBuilder();

            foreach (var sub in proc.Queries)
            {
                r.AppendLine("EXISTS (");
                r.AppendLine(sub.ToString());
                r.AppendLine("AND ");
            }

            var newContext = new SqlConversionContext
            {
                Alias    = context.ToSafeId(proc.TableAlias),
                Query    = context.Query,
                ToSafeId = context.ToSafeId,
                Type     = proc.Property.DeclaringType
            };

            r.Append(subCriterion.ToSqlOn(newContext));

            foreach (var sub in proc.Queries)
            {
                r.Append(")");
            }

            return(r.ToString());
        }