下面给出的是我用来从 Dynamodb 表中检索详细信息的方法。但是当我调用这个方法时,它最终抛出了一个异常“无法找到关键属性约会 ID 的属性”。这个特定表的主键是约会ID,但我已经在 PatientId 列上创建了一个全局二级索引。我在下面的查询中使用该索引来通过给定的患者 ID 获取预约详细信息。
public async Task GetAppointmentByPatientID(int patientID)
{
var context = CommonUtils.Instance.DynamoDBContext;
PatientAppointmentObjectList.Clear();
DynamoDBOperationConfig config = new DynamoDBOperationConfig();
config.IndexName = DBConstants.APPOINTMENT_PATIENTID_GSI;
AsyncSearch<ScheduledAppointment> appQuery = context.QueryAsync<ScheduledAppointment>(patientID.ToString(), config);
IEnumerable<ScheduledAppointment> appList = await appQuery.GetRemainingAsync();
appList.Distinct().ToList().ForEach(i => PatientAppointmentObjectList.Add(i));
if (PropertyChanged != null)
this.OnPropertyChanged("PatientAppointmentObjectList");
}
}