Sqlite一对多关系 [英] Sqlite One to Many Relationship

查看:738
本文介绍了Sqlite一对多关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在制作一个需要存储和从sqlite数据库获取数据的应用程序。我目前使用的两个Nuget包是 Sqlite PCL SQLite-Net Extensions

I'm currently making an app that needs to store and get data to and from a sqlite database. The two Nuget packages I'm currently using are Sqlite PCL and SQLite-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;}
}

整个事情编译得很好,但是当我尝试运行模拟器时,我收到了这条消息:

The whole thing is compiled fine, but when I try to run the simulator I'm getting this message:


System.NotSupportedException已被抛出不知道
System.Collections.Generic.List1

System.NotSupportedException has been thrown Don't know about System.Collections.Generic.List1

我检查了SQLite-Net Extensions 文档,它支持List 。

I checked the SQLite-Net Extensions documentation and it does support List.

有人知道如何解决这个问题吗?

Does anyone know how to fix this?

推荐答案

,经过一番研究,事实证明,我必须删除所有与SQLite相关的预算,并将其重新安装到项目中。在我的情况下,因为我需要SQLite-Net扩展,所以我只需要将它放在我的项目中,并且任何依赖项的修改都将与SQL-Net Extensions一起安装。

Anyway, after some research, it turned out that I had to remove all of the SQLite related nudgets and re-install them into the project. In my case, since I need the SQLite-Net Extensions, I only need to put it in my project and any dependencies nudgets will also be installed along with SQL-Net Extensions.

这篇关于Sqlite一对多关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆