Razor proxy type error. System.Data.Entity.DynamicProxies

前端 未结 2 395
北恋
北恋 2021-01-15 12:59

I have a class User and then another Type UserSpecial with some special user properties. I pass it in razor to the partial method class to create the UserSpecial form which

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-15 13:18

    No idea what userRepository.Current is but it seems that it doesn't correctly/eagerly load the UserSpecial property. Why don't you use view models? Why are you passing domain entity models to your views? That's bad practice. You should define view models that contain only the data that's required by your view and then in your controller action map between your domain models and the corresponding view model which will be passed to the view.

提交回复
热议问题