In the documentation for SQLite-Net Extensions, it shows having an object (Stock) with property that has a List of another object (Valuation) with a OneToMany relationship. I am able to reproduce that fine.
What I want to do is to be able to add a property to Stock that is a List of strings.
But when I try to add a List<string> property, if I have no attributes on it, I get the error: 'Don't know about System.Collections.Generic.List`1[System.String]'
If I add the [OneToMany] attribute to the property, I get the error: 'OneToMany relationships require Primary Key in the destination entity'
Is there any way that SQLite-Net Extensions can handle List<string> instead of List of non primative types?
Any kind of relationship requires a destination table. In your case, a
string
is not stored as a table. You can either convert that value into a complex object that is stored in a separate table and use either aOneToMany
or aManyToMany
or serialize the list as a string and save it in a different field.For the latter case SQLite-Net Extensions includes a
TextBlob
attribute that does exactly that. It serializes the property as a string before storing the objech to database and deserializes it after reading from database.More info in the manual.