Xamarin Forms Firebase DeleteAsync 逻辑 - 为什么删除第一项而不是第二项?
Xamarin Forms Firebase DeleteAsync logic - Why deletes first item instead of second item?
在我的代码中做的事情是当我删除第二个块而不删除第一个块时,要删除的是第一个而不是选定的第二个块。"
//This is where the listview item tapped
var certification = args.Item as Certifications;
if (certification == null) return;
await Navigation.PushAsync(new CertificationDetailsPage(certification));
lstCertifications.SelectedItem = null;
// This is the code to delete
var toDeleteCertification = (await client
.Child("Table => Certifications")
.OnceAsync<Certifications>()).FirstOrDefault(a => a.Object.FullName == fullName || a.Object.Email == email || a.Object.Address == address
|| a.Object.Occupation == occupation || a.Object.Age == age || a.Object.Sex == sex || a.Object.CivilStatus == civilStatus
|| a.Object.Date == date || a.Object.TypeofCertificate == typeofCertificate || a.Object.Purpose == purpose);
await client.Child("Table => Certifications").Child(toDeleteCertification.Key).DeleteAsync();
只是把这个答案放在这里,以确认 Beginnerton 解决了他们的问题。
删除表达式逻辑错误;需要 &&
而不是 ||
.
在我的代码中做的事情是当我删除第二个块而不删除第一个块时,要删除的是第一个而不是选定的第二个块。"
//This is where the listview item tapped
var certification = args.Item as Certifications;
if (certification == null) return;
await Navigation.PushAsync(new CertificationDetailsPage(certification));
lstCertifications.SelectedItem = null;
// This is the code to delete
var toDeleteCertification = (await client
.Child("Table => Certifications")
.OnceAsync<Certifications>()).FirstOrDefault(a => a.Object.FullName == fullName || a.Object.Email == email || a.Object.Address == address
|| a.Object.Occupation == occupation || a.Object.Age == age || a.Object.Sex == sex || a.Object.CivilStatus == civilStatus
|| a.Object.Date == date || a.Object.TypeofCertificate == typeofCertificate || a.Object.Purpose == purpose);
await client.Child("Table => Certifications").Child(toDeleteCertification.Key).DeleteAsync();
只是把这个答案放在这里,以确认 Beginnerton 解决了他们的问题。
删除表达式逻辑错误;需要 &&
而不是 ||
.