I have two entity classes created within my VS project
Category.cs
[JsonObject(MemberSerialization.OptIn)]
    [Table("Category")]
    public class Category
    {
        private string _id;
        private string _label;
        [JsonProperty(PropertyName = "id")]
        [PrimaryKey]
        public string ID
        {
            get { return _id; }
            set
            {
                if (_id != value)
                {
                    _id = value;
                }
            }
        }
        [JsonProperty(PropertyName = "label")]
        public string Label
        {
            get { return _label; }
            set
            {
                if (_label != value)
                {
                    _label = value;
                }
            }
        }
    }
Subscription.cs
[JsonObject(MemberSerialization.OptIn)]
    [Table("Subscription")]
    public class Subscription
    {
        private List<Category> _categories;
        private string _contentType;
        [JsonProperty(PropertyName = "categories")]
        [OneToMany(CascadeOperations = CascadeOperation.All)]
        public List<Category> Categories 
        {
            get { return _categories; }
            set
            {
                if (_categories != value)
                {
                    _categories = value;
                }
            }
        }
        [JsonProperty(PropertyName = "contentType")]
        public string ContentType
        {
            get { return _contentType; }
            set
            {
                if (_contentType != value)
                {
                    _contentType = value;
                }
            }
        }
}
I have included SQLite in project and when using the SQLiteConnection.InsertAll project it populates the required Table but doesn't populate the Sub-Object.
So if I had an ObservableCollection<Subscription> I would want to populate the list I have.
How would I go about ensuring my List<Category> is populated in the Subscription table of my database?
Aucun commentaire:
Enregistrer un commentaire