示例#1
0
        public Task BindModelAsync(ModelBindingContext bindingContext)
        {
            var model    = bindingContext.ModelName;
            var hasValue = false;

            if (!bindingContext.TryGetInt64($"{model}", ref hasValue, out var value))
            {
                return(Task.CompletedTask);
            }

            if (!bindingContext.TryGetInt64($"{model}.eq", ref hasValue, out var eq))
            {
                return(Task.CompletedTask);
            }

            if (!bindingContext.TryGetInt64($"{model}.ne", ref hasValue, out var ne))
            {
                return(Task.CompletedTask);
            }

            if (!bindingContext.TryGetInt64($"{model}.gt", ref hasValue, out var gt))
            {
                return(Task.CompletedTask);
            }

            if (!bindingContext.TryGetInt64($"{model}.ge", ref hasValue, out var ge))
            {
                return(Task.CompletedTask);
            }

            if (!bindingContext.TryGetInt64($"{model}.lt", ref hasValue, out var lt))
            {
                return(Task.CompletedTask);
            }

            if (!bindingContext.TryGetInt64($"{model}.le", ref hasValue, out var le))
            {
                return(Task.CompletedTask);
            }

            if (!bindingContext.TryGetInt64List($"{model}.in", ref hasValue, out var @in))
            {
                return(Task.CompletedTask);
            }

            if (!bindingContext.TryGetInt64List($"{model}.ni", ref hasValue, out var ni))
            {
                return(Task.CompletedTask);
            }

            if (!bindingContext.TryGetString($"{model}.eqx", ref hasValue, out var eqx))
            {
                return(Task.CompletedTask);
            }

            if (!bindingContext.TryGetString($"{model}.nex", ref hasValue, out var nex))
            {
                return(Task.CompletedTask);
            }

            if (!bindingContext.TryGetBool($"{model}.null", ref hasValue, out var isNull))
            {
                return(Task.CompletedTask);
            }

            if (!hasValue)
            {
                bindingContext.Result = ModelBindingResult.Success(null);
                return(Task.CompletedTask);
            }

            bindingContext.Result = ModelBindingResult.Success(new Int64ExParameter
            {
                Eq   = value ?? eq,
                Ne   = ne,
                Gt   = gt,
                Ge   = ge,
                Lt   = lt,
                Le   = le,
                In   = @in,
                Ni   = ni,
                Eqx  = eqx,
                Nex  = nex,
                Null = isNull
            });

            return(Task.CompletedTask);
        }