Exemplo n.º 1
0
        public FormattableString Build(IDapperCommandBuilder commandBuilder)
        {
            FormattableString expression = notExpression
                                           .Criterion
                                           .GetExpressionBuilder()
                                           .Build(commandBuilder);

            string commandTemplate = expression.Format;
            string notOperator     = notExpression.Criterion.GetNotOperator();

            var match = Regex.Match(commandTemplate, "(Between|Like|In|Null|=)");

            if (match.Success)
            {
                commandTemplate = Regex.Replace(
                    input: commandTemplate,
                    pattern: match.Value,
                    replacement: $"{notOperator}{match.Value}",
                    options: RegexOptions.IgnoreCase);
            }

            return(FormattableStringFactory.Create(
                       commandTemplate,
                       expression.GetArguments()));
        }
Exemplo n.º 2
0
        public FormattableString Build(IDapperCommandBuilder commandBuilder)
        {
            var expressions    = BuildExpressions(commandBuilder);
            var junctionFormat = $"({BuildFormat(expressions)})";

            return(FormattableStringFactory.Create(
                       junctionFormat,
                       expressions.ToArray()));
        }
        public FormattableString Build(IDapperCommandBuilder commandBuilder)
        {
            string       commandTemplate = nullExpression.GetCommandTemplate();
            IFormattable columnName      = Sql.Column(nullExpression.GetPropertyName());

            return(FormattableStringFactory.Create(
                       commandTemplate,
                       columnName));
        }
Exemplo n.º 4
0
        public FormattableString Build(IDapperCommandBuilder commandBuilder)
        {
            string       commandTemplate = inExpression.GetCommandTemplate();
            IFormattable columnName      = Sql.Column(inExpression.GetPropertyName());
            string       parameterName   = commandBuilder.AddExpressionValue(inExpression.Values);

            return(FormattableStringFactory.Create(
                       commandTemplate,
                       columnName,
                       parameterName));
        }
        protected IReadOnlyCollection <FormattableString> BuildExpressions(IDapperCommandBuilder commandBuilder)
        {
            var formattableExpression = new List <FormattableString>();

            foreach (IDapperExpressionBuilder builder in GetExpressionBuilders())
            {
                formattableExpression.Add(builder.Build(commandBuilder));
            }

            return(formattableExpression);
        }
        public FormattableString Build(IDapperCommandBuilder commandBuilder)
        {
            string       commandTemplate     = betweenExpression.GetCommandTemplate();
            IFormattable columnName          = Sql.Column(betweenExpression.GetPropertyName());
            string       parameterNameStarts = commandBuilder.AddExpressionValue(betweenExpression.Starts);
            string       parameterNameEnds   = commandBuilder.AddExpressionValue(betweenExpression.Ends);

            return(FormattableStringFactory.Create(
                       commandTemplate,
                       columnName,
                       parameterNameStarts,
                       parameterNameEnds));
        }
 public DapperSimpleExpressionTest(QueryFixture fixture)
 {
     commandBuilder = fixture.GetCommandBuilder();
 }