C# Sqlite一对多关系
我目前正在制作一个应用程序,需要在sqlite数据库中存储和获取数据。我目前使用的两个Nuget包是C# Sqlite一对多关系,c#,list,generics,xamarin,sqlite-net,C#,List,Generics,Xamarin,Sqlite Net,我目前正在制作一个应用程序,需要在sqlite数据库中存储和获取数据。我目前使用的两个Nuget包是Sqlite PCL和Sqlite Net Extensions [Table("patient")] public class Patient { [PrimaryKey] public string ID { get; set;} public string FirstName { get; set; } public string LastName { get; set;
Sqlite PCL
和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;}
}
[表格(“患者”)]
公立病人
{
[主密钥]
公共字符串ID{get;set;}
公共字符串名{get;set;}
公共字符串LastName{get;set;}
[一家公司]
公共列表PatientVitals{get;set;}
}
[表(“患者资料”)]
公立医院
{
[主密钥]
公共字符串VitalID{get;set;}
公共字符串权重{get;set;}
公共字符串高度{get;set;}
[外键(患者类型))]
公共字符串SmartCardID{get;set;}
}
整个过程编译得很好,但当我尝试运行模拟器时,我得到了以下消息:
System.NotSupportedException已被抛出不知道
System.Collections.Generic.List1
我检查了SQLite网络扩展,它确实支持列表
有人知道如何解决这个问题吗?请将Patient的主键作为外键添加到PatientVitals表中。无论如何,经过一些研究,我不得不删除所有与SQLite相关的微动,并将它们重新安装到项目中。在我的例子中,因为我需要SQLite网络扩展,所以我只需要将它放在我的项目中,任何依赖项轻推也将与SQL网络扩展一起安装。不起作用,收到相同的消息。不过谢谢!我想他们正在(或正在)解决列表问题。这是公共字符串SmartCardID。您必须将
[ForeignKey(typeof(PatientItem))]
更改为[ForeignKey(typeof(patientiem))]