0

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.

1
  • I'm not very familiar with SQLite in C#, but typically when you have an object that contains a list of other objects (which would have its own DB table), you'd insert the base object first, then insert all the aggregated objects after (referring to the owner by foreign key). If the DBMS supports it, you might be able to insert all these tags at once. Otherwise you'd have to iterate through them and insert one by one (in which case you'd probably want to wrap the whole thing in a transaction in case one fails, you can undo the whole operation). Commented Apr 8, 2015 at 3:18

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.