Zero or more to many relationship
Issue #48
closed
How can I accomplish this? I have files that can be inside a folder, or not (such as root files), and folders can be sub-folders with a parent folder, or root folders themselves. So I need 2 relationships of ZeroOrMoreToMany.
The file class is:
public class UserFile { [PrimaryKey, AutoIncrement] public int ID { get; set; }
[ManyToOne(inverseProperty: "Files")]
public UserFolder Folder { get; set; }
[ForeignKey(typeof(UserFolder))]
public int? FolderID { get; set; }
}
And the folder class is:
public class UserFolder { [PrimaryKey, AutoIncrement] public int ID { get; set; }
[ManyToOne(inverseProperty: "SubFolders")]
public UserFolder ParentFolder { get; set; }
[OneToMany(inverseProperty: "ParentFolder")]
public List<UserFolder> SubFolders { get; set; }
[OneToMany(inverseProperty: "Folder")]
public List<UserFile> Files { get; set; }
}
Comments (2)
-
-
- changed status to closed
Almost one month of inactivity. Closing
- Log in to comment
Please ask this kind of questions in StackOverflow as described in the project description.
ZeroOrMoreToMany is
OneToMany
. The zero is always implied.You are missing the parent folder ID foreign key. It should look like this