Can I use a list of strings in a class designed for SQLite?

What are the restrictions on the data types used in the class that SQLite-net will use to represent the table? In particular, can I use this:

public List<string> CoconutWaterBrands { get; set; }

... or do I need it:

public string[] CoconutWaterBrands { get; set; }

... or something else?

+12
source share
3 answers

ORM (, ) ​​. . List , ORM - , - , , , .

, / SQLite-net. ( ) " ".

+10

Sandy Answer, / , Text blobbed properties SQLite-Net, , , Model:

public class SomethingToDoWithCoconuts
{
    [TextBlob(nameof(CoconutWaterBrandsBlobbed))]
    public List<string> CoconutWaterBrands { get; set; }
    public string CoconutWaterBrandsBlobbed { get; set; } // serialized CoconutWaterBrands
}

blobbed Text:

text-blobbed text . .

blobbed , , List Dictionary . blobbed , .

text-blobbed .

JSON , TextBlobOperations.SetTextSerializer. JSON, Newtonsoft Json.Net, NuGet.

+10

, Newtonsoft.Json JSON:

..

private string coconutWaterBrands;

[Ignore]
public List<string> CoconutWaterBrands { 
    get
    {
        return JsonConvert.DeserializeObject<List<string>>(coconutWaterBrands);
    } 
    set
    {
        coconutWaterBrands = JsonConvert.SerializeObject(value);
    }
}
+8

All Articles