2

I install SQLiteNetExtensions from nuget using Visual Studio 2015 in a UWP project. This is my model:

public class MovieItem 
{
    [PrimaryKey]
    public string Url { get; set; }

    [OneToMany(CascadeOperations = CascadeOperation.All)]
    public List<EpisodeItem> Episodes { get; private set; }
}

public class EpisodeItem 
{
    private bool _selected;

    [PrimaryKey]
    public string Url { get; internal set; }

    [ForeignKey(typeof(MovieItem))]
    public string MovieUrl { get; set; }

    [ManyToOne]
    public MovieItem Movie { get; set; }
}

But when I run:

var movieItem = new MovieItem{
    Url='movie link',
    Episodes = new List<Episode>{
       Url='episode link'
    }
};
conn.InsertWithChildren(movieItem,true);

And open database file with SqliteBrowser. I get only MovieItem record without any Episode record. I have tried many ways but it still does not work.

Vinh Le
  • 101
  • 1
  • 3

1 Answers1

1

Try changing the Episodes setter to public:

public class MovieItem 
{
    [PrimaryKey]
    public string Url { get; set; }

    [OneToMany(CascadeOperations = CascadeOperation.All)]
    public List<EpisodeItem> Episodes { get; set; }
}
redent84
  • 18,901
  • 4
  • 62
  • 85