Esempio n. 1
0
        public virtual async Task <bool> TryUpdateModelAsync <TModel>([NotNull] TModel model,
                                                                      [NotNull] string prefix,
                                                                      [NotNull] IValueProvider valueProvider)
            where TModel : class
        {
            if (BindingContextProvider == null)
            {
                var message = Resources.FormatPropertyOfTypeCannotBeNull("BindingContextProvider", GetType().FullName);
                throw new InvalidOperationException(message);
            }

            var bindingContext = await BindingContextProvider.GetActionBindingContextAsync(ActionContext);

            return(await ModelBindingHelper.TryUpdateModelAsync(model,
                                                                prefix,
                                                                ActionContext.HttpContext,
                                                                ModelState,
                                                                bindingContext.MetadataProvider,
                                                                bindingContext.ModelBinder,
                                                                valueProvider,
                                                                bindingContext.ValidatorProvider));
        }
        private Func <ModelBindingContext, string, bool> GetPredicateFromExpression(IEnumerable <Expression <Func <TModel, object> > > includeExpressions)
        {
            var expression = ModelBindingHelper.GetIncludePredicateExpression(Prefix, includeExpressions.ToArray());

            return(expression.Compile());
        }