Example #1
0
            IDatabaseQuery WhereSubquery(string myField, IDatabaseQuery subquery, string targetField, string @operator)
            {
                subquery.AliasPrefix = "Subq" + Guid.NewGuid().ToString().Remove("-").Substring(0, 6);

                var sql = subquery.Provider
                          .GenerateSelectCommand(subquery, subquery.MapColumn(targetField));

                sql = $"{MapColumn(myField)} {@operator} ({sql})";
                Criteria.Add(Criterion.FromSql(sql));

                foreach (var subQueryParam in subquery.Parameters)
                {
                    Parameters.Add(subQueryParam.Key, subQueryParam.Value);
                }

                return(this);
            }