我正在尝试在同一个表中添加类别之间的关系。我有一个
类别(ID 整数主键自动增量,名称文本)
表和
CATEGORIES_CATEGORIES (ID INTEGER PRIMARY KEY AUTOINCREMENT, CATEGORIES_ID INTEGER NOT NULL, SUBCATEGORIES_ID INTEGER NOT NULL)
桌子。
我正在尝试将它们与 Vici Coolstorage ORM 映射在一起。我已经上课了
类别类
[MapTo("CATEGORIES")]
public abstract class Category : CSObject<Category>
{
public abstract int Id { get; }
public abstract string Name { get; set; }
[ManyToMany("CATEGORIES_CATEGORIES", Pure = true)]
public abstract CSList<CategoryCategory> Subcategories { get; set; }
}
CategoryCategory 类
[MapTo("CATEGORIES_CATEGORIES")]
public abstract class CategoryCategory : CSObject<CategoryCategory>
{
public abstract int Id { get; }
[ManyToOne(LocalKey = "CATEGORIES_ID", ForeignKey = "ID")]
public abstract Category Cat { get; set; }
[ManyToOne(LocalKey = "SUBCATEGORIES_ID", ForeignKey = "ID")]
public abstract Category SubCat { get; set; }
}
但我不能让它工作。任何人都可以帮助我让这种关系发挥作用吗?