【发布时间】:2012-10-08 09:14:52
【问题描述】:
List<DynamicBusinessObject> dbo = SearchController.Instance.GetSearchResultList(search, null, "date", startRow - 1, ucDataPager1.PageSize, state);
上面的代码行调用 GetSearchResultList 方法,到目前为止该方法有 5 个参数。
我添加了第 6 个参数,但想让这个参数成为可选参数,这样调用这个函数的所有其他页面就不需要更新了。
所以我把函数改成这样:
[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
public List<DynamicBusinessObject> GetSearchResultList(Search search, List<CategoryAttribute> listCatAttrib, string sortBy, int startRow, int pageSize, [Optional, DefaultParameterValue("")] string state)
{
StorageQuery qry = new QrySearchResult(
search.ID,
(listCatAttrib != null && listCatAttrib.Count > 0) ? listCatAttrib[0].Attribute.ID : -1,
(listCatAttrib != null && listCatAttrib.Count > 1) ? listCatAttrib[1].Attribute.ID : -1,
(listCatAttrib != null && listCatAttrib.Count > 2) ? listCatAttrib[2].Attribute.ID : -1,
1, sortBy, startRow, pageSize, state);
List<DynamicBusinessObject> list = BusinessObject.Search(qry);
return list;
}
但是,当我尝试构建时,它给了我 GetSearchResultList 没有重载方法并且需要 5 个参数的错误。 我也尝试过使用 string state = "" 而不是使用 [Optional]
如果第 6 个参数是可选的,那么有人知道为什么它抱怨我在调用时没有传递 6 个参数吗?
【问题讨论】: