문제

I have a DropDownList that particpates in an Address View Model.

Is it best to store the list of 170 or so countries in a database and load them into a collection on the View Model, or is it better to hard code them into the View Model as a collection containing SelectListItems?

Which is best practice?

When does hardcoding SelectListItems become too many as most people would choose to hardcode the title of a name: Mr, Miss, Ms, and Mrs....

도움이 되었습니까?

해결책

I would definitely advise putting them in a database.

ASP.Net MVC has some nice caching features so using those you won't be making a live call to your database for every user that hits that page.

So since the data call can be cached there is no real downside to putting them in the database but quite a few upsides.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top