3

On a windows store app project i get a JSON from a webservice that looks like this:http://paste2.org/jfMJ2AGA

and i have these 2 classes

public class media
{
    public string id { get; set; }
    public string type { get; set; }
    public string image { get; set; }
    public string video { get; set; }
    public string snapshot { get; set; }
    public string url { get; set; }
    public string snapshot_url { get; set; }
}

public class artigos
{
    public string menu { get; set; }
    public string submenu { get; set; }
    public string title { get; set; }
    public string subtitle { get; set; }
    public string description { get; set; }
    public List<media> media { get; set; }
}

and im creating a sqlite database with:

dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "Database.sqlite");

//start dB
using (var db = new SQLite.SQLiteConnection(dbPath))
{
    db.CreateTable<artigos>();
}

but i get this error:

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

Am i doing anything wrong?

3
  • Did you ever find a workaround? Commented May 27, 2016 at 1:42
  • it has been a while, but if i recall i think i saved a json string with media objects ids, something like [ "1234","5678","9012","3456" ] Commented May 27, 2016 at 9:24
  • That's exactly the approach I was going to take. Thank you! Commented May 27, 2016 at 20:55

2 Answers 2

4

Sqllite does not support lists. This means that you can´t have

public List<media> media { get; set; } 
Sign up to request clarification or add additional context in comments.

Comments

0

I had the same problem with an int[] and I did this:

[Table(nameof(Folder))]
public class Folder
{
    public Folder()
    {
        // for SQLite
    }
    internal Folder(Json.Folder folder)
    {
        Id = folder.id;
        Title = folder.title;
        Lists = string.Join(",", folder.list_ids);
    }

    [PrimaryKey]
    public int Id { get; set; }
    public string Title { get; set; }
    public string Lists { get; set; }
    public int[] ListsArray => Lists.Split(',').Select(x => int.Parse(x)).ToArray();
}

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.