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))); } }
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)); }
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)); }
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)); }
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)); }
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; }
public BinaryParametersDeleteQueryBuilder(IDeleteQueryBuilder <TRecord> deleteQueryBuilder, UniqueParameter startParameter, UniqueParameter endParameter) { this.deleteQueryBuilder = deleteQueryBuilder; this.startParameter = startParameter; this.endParameter = endParameter; }
public UnaryParameterDeleteQueryBuilder(IDeleteQueryBuilder <TRecord> deleteQueryBuilder, UniqueParameter parameter) { this.deleteQueryBuilder = deleteQueryBuilder; this.parameter = parameter; }