简体   繁体   中英

C# How to add in DB SQLite a list<string>

It's the first time I work with SQLite DB, I'm trying to add a List in my table.

This is my class :

public DbF(string title, string content, bool myfavoris, int partner, List<string> tags)

I add like that :

obj.Insert(new DbFavoris(title, content, true, partner, tags));

I got this error :

Don't know about System.Collections.Generic.List`1[System.String]

I realized after searching, we can't add directly a List but I don't know how to do because I retrieved my tags with a JSON I put the data immediately in a List.

SQLLite does not support lists. Which means you can't use List<string> tags . Similar question was also asked here . Perhaps, you can try storing your tags as pipe separated strings like 'Tag1|Tag2|Tag3' and manipulate it during retrieval. Or you can try changing you schema.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM