2015-08-18 69 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一起安装。