[英]error while returning data from firebase in xamarin app
我有一个 c# 应用程序,它处理 firebase 数据库,以便从中获取特定项目的数据An object reference is required for the non-static field, method, or property
在AppintmentService.GetFollowUp(patient.ID)
) 中返回此错误AppintmentService.GetFollowUp(patient.ID)
线,我做错了什么?
public ICommand Appearing { get => _Appearing; set => SetProperty(ref _Appearing, value, nameof(Appearing)); }
public PatientProfileFollowUpPageModelView(Patient patient)
{
Appearing = new AsyncCommand(async () => await LoadData(patient));
}
function:
async Task LoadData(Patient patient)
{
Appoitments = new ObservableCollection<Appoitment>(await AppintmentService.GetFollowUp(patient.ID));
}
和服务:
public ObservableCollection<Appoitment> GetFollowUp(string PatientID)
{
var FollowUp = firebaseClient
.Child($"Specalists/{PreferencesConfig.Id}/Patients/{PatientID}/Appointments")
.AsObservable<Appoitment>()
.AsObservableCollection();
return FollowUp;
}
GetFollowUp
是 class AppintmentService
上的一个方法,因此您需要一个AppintmentService
实例才能调用它。
var svc = new AppintmentService);
var result = svc.GetFollowUp(patient.ID)
或者,您可以使GetFollowUp
成为static方法,这样您就可以在没有实例的情况下调用它
在任何一种情况下, GetFollowUp
都没有标记为 async ,因此不需要使用await
调用它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.