Default value in an asp.net mvc view model

后端 未结 6 566
星月不相逢
星月不相逢 2020-12-05 01:37

I have this model:

public class SearchModel
{
    [DefaultValue(true)]
    public bool IsMale { get; set; }
    [DefaultValue(true)]
    public bool IsFemale         


        
6条回答
  •  感情败类
    2020-12-05 02:12

    What will you have? You'll probably end up with a default search and a search that you load from somewhere. Default search requires a default constructor, so make one like Dismissile has already suggested.

    If you load the search criteria from elsewhere, then you should probably have some mapping logic.

提交回复
热议问题