2015-08-18 68 views
5

我目前正在製作一個應用程序,需要存儲和從sqlite數據庫獲取數據。我目前使用的兩個Nuget包是Sqlite PCLSQLite-Net ExtensionsSqlite一對多關係

[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 documentation,它支持List。

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

+0

不起作用,得到相同的消息。但是,謝謝! – Fayt

+0

我瘦了,他們正在修復(或工作)修復List <>問題。 [link](https://bitbucket.org/twincoders/sqlite-net-extensions/pull-requests/12/support-ilist-instead-of-list-as-enclosed/diff#comment-8587796) – Roman

回答

0

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

+0

這是公衆字符串SmartCardID。 – Fayt

+0

'[ForeignKey(typeof(PatientItem))]' 到 '[ForeignKey(typeof(Patien))]] [ –

0

無論如何,經過一番研究,事實證明,我必須刪除所有與SQLite相關的預算,並將其重新安裝到項目中。在我的情況下,因爲我需要SQLite-Net擴展,所以我只需要將它放在我的項目中,並且任何依賴項的修改都將與SQL-Net Extensions一起安裝。