我有一个类属性,如下所示:
public List<Recipe> RecipeList
{
get { return this._recipeList; }
set
{
this._recipeList = value;
OnPropertyChanged("RecipeList");
}
}
在另一种方法中,我引用了上面提到的属性。
private void RecipeSearch()
{
this.RecipeList = RecipeManagerService.SearchByUnit(SearchCriteria)
.Where(recipe => recipe.IsApproved == true && !recipe.IsHidden).ToList();
}
代码分析发出CA 2227警告:通过删除setter将RecipeList更改为只读。有人能告诉我为什么吗?