Пример #1
0
        protected void bindNavigationProperty <T>(Expression <Func <TModel, T> > propertyExpression,
                                                  ControllerContext controllerContext, ModelBindingContext bindingContext)
            where T : class, IHasId
        {
            string name = propertyExpression.GetPropertyName();
            int?   id   = getValue <int?>(name, bindingContext);

            if (id.HasValue)
            {
                T value = controllerContext.Db().Set <T>().SingleOrDefault(x => x.Id == id);
                setProperty(bindingContext, name, value);
            }
        }