vendredi 23 octobre 2015

SQLiteNetExtensions OneToMany and ManyToOne Relationships not working

I have a problem with SQLite-Net I have three classes: ClassA, ClassB, ClassC. ClassA has OneToMany relation with ClassB. ClassB has ManyToOne Relation with ClassC.

This is my code

    using System;
    using System.Collections.Generic;
    using System.Xml.Serialization;
    using SQLite.Net.Attributes;
    using SQLiteNetExtensions.Attributes;
    using WardFlex.Core.DAL.Interfaces;

        public class ClassA : IEntity
        {
            [XmlAttribute("Id")]
            [PrimaryKey, AutoIncrement]
            public Int64 Id { get; set; }

            public string Kaka { get; set; }

            [OneToMany(CascadeOperations = CascadeOperation.All)]
            public  List<ClassB> ClassBs { get; set; }
        }


        public class ClassB : IEntity
        {
            [XmlAttribute("Id")]
            [PrimaryKey, AutoIncrement]
            public Int64 Id { get; set; }

            [ForeignKey(typeof(ClassA))]
            public Int64 ClassAId { get; set; }

            [ManyToOne]
            public  ClassA ClassA { get; set; }

            [ForeignKey(typeof(ClassC))]
            public Int64 ClassCId { get; set; }

            [ManyToOne]
            public ClassC ClassC { get; set; }
        }        

    public class ClassC : IEntity
    {
        [XmlAttribute("Id")]
        [PrimaryKey, AutoIncrement]
        public Int64 Id { get; set; }

        [OneToMany(CascadeOperations = CascadeOperation.All)]
        public List<ClassB> ClassBs { get; set; }
    }

I Save ClassA entity, but When I try GetAllWithChildren From ClassARepository I can't to see classC entity from ClassB(image was attached) enter image description here

What could be the problem??

Thank you in advance

Aucun commentaire:

Enregistrer un commentaire