public MainViewModel()
{
ClientDeleteCommand = new DelegateCommand<string>(ClientDelete);
}
public DelegateCommand<string> ClientDeleteCommand { get; set; }
private void ClientDelete(string phone)
{
using BookStoreContext context= new BookStoreContext();
Client client = context.Clients.FirstOrDefault(x => x.Phone == phone);
context.Clients.Remove(client);
int count = context.SaveChanges();
}
如上,<string>是可行的。
而<int>不可行,会报错。
具体原因只查到了(其中链接打不开)
可能等以后知道了具体原因再来填坑(?)