我試圖在同一個表中的類別之間添加關係。我有一個ManyToMany與同一張表的關係
類別(ID INTEGER PRIMARY KEY AUTOINCREMENT,NAME TEXT)
表和
CATEGORIES_CATEGORIES(ID INTEGER PRIMARY KEY AUTOINCREMENT, CATEGORIES_ID INTEGER NOT NULL,SUBCATEGORIES_ID INTEGER NOT NULL)
表。
我試圖將它們與Vici Coolstorage ORM一起映射。我做了類
Category類
[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; }
}
但我不能使它發揮作用。任何人都可以幫助我獲得這種關係嗎?
什麼行不通。請詳細說明。 – Cheesebaron 2013-03-03 21:37:36