明示的にproperty属性に外部キーと逆の関係を指定する必要があります。
public class TwitterUser {
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public string Name { get; set; }
[ManyToMany(typeof(FollowerLeaderRelationshipTable), "LeaderId", "Followers",
CascadeOperations = CascadeOperation.All)]
public List<TwitterUser> FollowingUsers { get; set; }
// ReadOnly is required because we're not specifying the followers manually, but want to obtain them from database
[ManyToMany(typeof(FollowerLeaderRelationshipTable), "FollowerId", "FollowingUsers",
CascadeOperations = CascadeOperation.CascadeRead, ReadOnly = true)]
public List<TwitterUser> Followers { get; set; }
}
// Intermediate class, not used directly anywhere in the code, only in ManyToMany attributes and table creation
public class FollowerLeaderRelationshipTable {
public int LeaderId { get; set; }
public int FollowerId { get; set; }
}
あなたの関係ではなく、「親子」の「兄・弟」である場合には、例えば、双方の関係を合計する必要があります:ここ
public class Person {
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public string Name { get; set; }
[ManyToMany(typeof(BrothersRelationshipTable), "OldBrotherId", "YoungerBrothers",
CascadeOperations = CascadeOperation.All)]
public List<Person> OlderBrothers { get; set; }
[ManyToMany(typeof(BrothersRelationshipTable), "YoungBrotherId", "OlderBrothers",
CascadeOperations = CascadeOperation.CascadeRead, ReadOnly = true)]
public List<Brothers> YoungerBrothers { get; set; }
[Ignore]
publc List<TwitterUser> Brothers {
get { return YoungerBrothers.Concat(OlderBrothers).ToList() }
}
}
// Intermediate class, not used directly anywhere in the code, only in ManyToMany attributes and table creation
public class BrothersRelationshipTable {
public int OldBrotherId { get; set; }
public int YoungBrotherId { get; set; }
}
同じ質問..次の項目を確認してください:http://stackoverflow.com/questions/14227468/in-sqlite-how-to-implement-a-many-to-many-relationship –