我有 ac# 應用程式,它處理 firebase 資料庫,以便從中獲取特定專案的資料,并An object reference is required for the non-static field, method, or property
回傳此錯誤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));
}
功能 :
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;
}
uj5u.com熱心網友回復:
GetFollowUp
是類的一個方法,AppintmentService
所以你需要一個實體AppintmentService
才能呼叫它。
var svc = new AppintmentService);
var result = svc.GetFollowUp(patient.ID)
或者,您可以創建GetFollowUp
一個靜態方法,這將允許您在沒有實體的情況下呼叫它
在任何一種情況下,GetFollowUp
都沒有標記為 asyncawait
,因此不需要使用它來呼叫它
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/470493.html
標籤:C# 火力基地 xml xamarin xamarin.forms
上一篇:xamarin導航登錄管理