InsertOrReplaceAllWithChildren insertion levels
Hi there!
I have an issue regarding inserting data into a SQLite database using the SQLite-Net Extensions InsertOrReplaceAllWithChildren() method.
The situation in short:
Class A:
[PrimaryKey] public int Id { get; set; }
[OneToMany(CascadeOperations = CascadeOperation.All)] public List<B> B { get; set; }
Class B:
[PrimaryKey] public int Id { get; set; }
[ForeignKey(typeof(A))] public int Aid { get; set; }
[OneToMany(CascadeOperations = CascadeOperation.All)] public List<C> C { get; set; }
Class C:
[PrimaryKey] public int Id { get; set; }
[ForeignKey(typeof(B))] public int Bid { get; set; }
[OneToMany(CascadeOperations = CascadeOperation.All)] public List<D> D { get; set; }
Class D:
[PrimaryKey] public int Id { get; set; }
[ForeignKey(typeof(C))] public int Cid { get; set; }
When I call : InsertOrReplaceAllWithChildren(_a); to insert an instance of type A which has a list of B's, which has a list of C's, which has a list of D's -> The foreign key between class A and B gets set properly, but the foreign key between B, C and C, D stays 0. Doesn't InsertOrReplaceAllWithChildren support this kind of operation or am I doing something wrong here?
Best regards,
Bas
Comments (2)
-
-
reporter - changed status to closed
- Log in to comment
Did you set
recursive
parameter totrue
when callingInsertOrReplaceAllWithChildren
?