所以我有一个名为Repository的类,它拥有这个方法:
public IEnumerable<TModel> UpdateOrCreate<TModel>(ICollection<TModel> itemsToUpdate)
where TModel : EndpointModelBase
{
//Do Stuff
}
如何使用正确的参数调用此方法? 我的麻烦来自于尝试为要传入的参数设置ICollection?
答案 0 :(得分:3)
您可以传递List<EndpointModelBase>
,因为它实现了ICollection<T>
。
List<EndpointModelBase> itemsToUpdate = new List<EndpointModelBase>();
UpdateOrCreate<EndpointModelBase>(itemsToUpdate);