问题
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 has been thrown Don't know about System.Collections.Generic.List1
I checked the SQLite-Net Extensions documentation and it does support List.
Does anyone know how to fix this?
回答1:
Please add the primary key of Patient as Foreign key in table PatientVitals.
回答2:
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.
来源:https://stackoverflow.com/questions/32081303/sqlite-one-to-many-relationship