Exemplo n.º 1
0
        public async Task <bool> AnyAsync(CancellationToken cancellationToken = default)
        {
            const int trueValue      = 1;
            const int falseValue     = 0;
            var       trueParameter  = new UniqueParameter(uniqueParameterNameGenerator, new Parameter("true"));
            var       falseParameter = new UniqueParameter(uniqueParameterNameGenerator, new Parameter("false"));

            var result = await readQueryExecutor.ExecuteScalarAsync <int>(CreateQuery().GenerateSql(), CreateParameterValues(), RetriableOperation.Select, commandTimeout, cancellationToken);

            return(result != falseValue);

            CommandParameterValues CreateParameterValues()
            {
                return(new CommandParameterValues(paramValues)
                {
                    { trueParameter.ParameterName, trueValue },
                    { falseParameter.ParameterName, falseValue }
                });
            }

            IExpression CreateQuery()
            {
                var clonedSelectBuilder = selectBuilder.Clone();

                clonedSelectBuilder.RemoveOrderBys();
                return(new IfExpression(new ExistsExpression(clonedSelectBuilder.GenerateSelectWithoutDefaultOrderBy()),
                                        new SelectConstant(trueParameter),
                                        new SelectConstant(falseParameter)));
            }
        }
Exemplo n.º 2
0
        public IUnaryParameterQueryBuilder <TRecord> WhereParameterized(string fieldName, UnarySqlOperand operand, Parameter parameter)
        {
            var uniqueParameter = new UniqueParameter(uniqueParameterNameGenerator, parameter);

            selectBuilder.AddWhere(new UnaryWhereParameter(fieldName, operand, uniqueParameter));
            return(new UnaryParameterQueryBuilder <TRecord>(Parameter(uniqueParameter), uniqueParameter));
        }
Exemplo n.º 3
0
        public IBinaryParametersQueryBuilder <TRecord> WhereParameterized(string fieldName, BinarySqlOperand operand,
                                                                          Parameter startValueParameter, Parameter endValueParameter)
        {
            var uniqueStartParameter = new UniqueParameter(uniqueParameterNameGenerator, startValueParameter);
            var uniqueEndParameter   = new UniqueParameter(uniqueParameterNameGenerator, endValueParameter);

            selectBuilder.AddWhere(new BinaryWhereParameter(fieldName, operand, uniqueStartParameter, uniqueEndParameter));
            return(new BinaryParametersQueryBuilder <TRecord>(Parameter(uniqueStartParameter).Parameter(uniqueEndParameter), uniqueStartParameter, uniqueEndParameter));
        }
Exemplo n.º 4
0
        public IUnaryParameterDeleteQueryBuilder <TRecord> WhereParameterised(string fieldName, UnarySqlOperand operand,
                                                                              Parameter parameter)
        {
            var uniqueParameter = new UniqueParameter(uniqueParameterNameGenerator, parameter);

            return(new UnaryParameterDeleteQueryBuilder <TRecord>(
                       AddWhereClause(new UnaryWhereClause(new WhereFieldReference(fieldName), operand, uniqueParameter.ParameterName)),
                       uniqueParameter));
        }
Exemplo n.º 5
0
        public IBinaryParametersDeleteQueryBuilder <TRecord> WhereParameterised(string fieldName,
                                                                                BinarySqlOperand operand, Parameter startValueParameter,
                                                                                Parameter endValueParameter)
        {
            var uniqueStartParameter = new UniqueParameter(uniqueParameterNameGenerator, startValueParameter);
            var uniqueEndParameter   = new UniqueParameter(uniqueParameterNameGenerator, endValueParameter);

            return(new BinaryParametersDeleteQueryBuilder <TRecord>(
                       AddWhereClause(new BinaryWhereClause(new WhereFieldReference(fieldName), operand, uniqueStartParameter.ParameterName, uniqueEndParameter.ParameterName)),
                       uniqueStartParameter,
                       uniqueEndParameter));
        }
Exemplo n.º 6
0
 public BinaryParametersQueryBuilder(IQueryBuilder <TRecord> queryBuilder, UniqueParameter startParameter, UniqueParameter endParameter)
 {
     this.queryBuilder   = queryBuilder;
     this.startParameter = startParameter;
     this.endParameter   = endParameter;
 }
 public UnaryParameterQueryBuilder(IQueryBuilder <TRecord> queryBuilder, UniqueParameter parameter)
 {
     this.queryBuilder = queryBuilder;
     this.parameter    = parameter;
 }
Exemplo n.º 8
0
 public BinaryParametersDeleteQueryBuilder(IDeleteQueryBuilder <TRecord> deleteQueryBuilder, UniqueParameter startParameter, UniqueParameter endParameter)
 {
     this.deleteQueryBuilder = deleteQueryBuilder;
     this.startParameter     = startParameter;
     this.endParameter       = endParameter;
 }
Exemplo n.º 9
0
 public UnaryParameterDeleteQueryBuilder(IDeleteQueryBuilder <TRecord> deleteQueryBuilder, UniqueParameter parameter)
 {
     this.deleteQueryBuilder = deleteQueryBuilder;
     this.parameter          = parameter;
 }