我的 Api 控制器中有以下内容:
[AcceptVerbs("POST")]
public Model.ViewModel.ContactSaveRequest DeleteMethod(Model.ViewModel.ContactSaveRequest methodsToDelete)
{
var contactMethodRepos = new Model.ContactMethodRepository();
foreach (var contactMethod in methodsToDelete)
{
contactMethodRepos.Delete(contactMethod);
return contactMethod;
}
}
这是我的类定义一个联系方法
[JsonProperty("id")]
public int ID { get; set; }
[JsonProperty("contactID")]
public int ContactID { get; set; }
[JsonProperty("typeOfContactMethodID")]
public int TypeOfContactMethodID { get; set; }
[JsonProperty("text")]
public string Text { get; set; }
[JsonProperty("methodsToDelete")]
public IEnumerable<ContactMethod> methodsToDelete { get; set; }
ContactSaverequest
班级:
public class ContactSaveRequest
{
[JsonProperty("contact")]
public Contact Contact { get; set; }
[JsonProperty("contactMethods")]
public IEnumerable<ContactMethod> ContactMethods { get; set; }
}
我有一个数组,它将方法推入其中以被删除(methodsToDelete
)。我正在尝试Delete
在数组上使用该方法,但不断遇到contactSaveRequest
不包含GetEnumerator
.