簡體   English   中英

Sqlite一對多關系

[英]Sqlite One to Many Relationship

我目前正在制作一個需要存儲和從sqlite數據庫獲取數據的應用程序。 我目前使用的兩個Nuget包是Sqlite PCLSQLite-Net Extensions

[Table("patient")]
public class Patient
{
[PrimaryKey]
public string ID { get; set;}

    public string FirstName { get; set; }
    public string LastName { get; set; }

    [OneToMany]
    public List<PatientVitals> PatientVitals { get; set; }
}

[Table("patientVitals")]
public class PatientVitals
{
    [PrimaryKey]
    public string VitalID {get;set;}

    public string Weight { get; set;}
    public string Height { get; set;}

    [ForeignKey(typeof(Patient))]
    public string SmartCardID {get;set;}
}

整個過程編譯得很好,但是當我嘗試運行模擬器時,我收到了這條消息:

拋出System.NotSupportedException不知道System.Collections.Generic.List1

我檢查了SQLite-Net Extensions 文檔 ,它確實支持List。

有誰知道如何解決這一問題?

請在表PatientVitals中添加Patient的主鍵作為外鍵。

無論如何,經過一些研究,結果發現我必須刪除所有與SQLite相關的nudgets並將它們重新安裝到項目中。 在我的例子中,由於我需要SQLite-Net Extensions,我只需要將它放在我的項目中,任何依賴項nudgets也將與SQL-Net Extensions一起安裝。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM