私は Web を探し回っていますが、WindowsPhone エミュレーターでのデータベースの作成を高速化する解決策が見つかりませんでした。そして私の質問:多対多の関係をスピードアップする方法はありますか? SimilarCollection
データベースを作成するには、 for everyのリストを追加する必要があり、そのそれぞれに、いくつかの Word への参照を格納する必要があるものをいくつかWord
追加する必要があります。WordJunctionSimilar
それはイライラするし、本当に複雑です。より良い解決策はありますか?
(コードのみSimilarCollection
がWordJunctionSimilar
重要です)
[Table]
public class Word
{
[Table]
public class SimilarCollection
{
[Column(IsPrimaryKey = true)]
public int SimilarId { get; set; }
[Column]
public string Translation { get; set; }
[Column]
public int? WordId { get; set; }
private EntitySet<WordJunctionSimilar> junction;
[Association(Name = "FK_Similar_Words1", Storage = "junction", ThisKey = "SimilarId", OtherKey = "SimilarId")]
public EntitySet<WordJunctionSimilar> Junction
{
get { return junction; }
set { junction = value; }
}
public SimilarCollection()
{
Junction = new EntitySet<WordJunctionSimilar>((w) => w.SimilarId = this.SimilarId,(w) => w.SimilarId = 0);
}
}
[Column(IsPrimaryKey = true)]
public int WordId { get; set; }
[Column(CanBeNull = false)]
public string Foreign { get; set; }
[Column]
public string Conjugation { get; set; }
[Column]
public string SpeechPart { get; set; }
[Column]
public string Type { get; set; }
private EntitySet<SimilarCollection> similar;
[Association(Name = "FK_Words_Similar", ThisKey = "WordId", OtherKey = "WordId", Storage = "similar")]
public EntitySet<SimilarCollection> Similar
{
get { return similar; }
set { similar = value; }
}
public Word()
{
Conjugation = "";
SpeechPart = "";
Type = "";
Similar = new EntitySet<SimilarCollection>(OnSimilarAdded,OnSimilarRemoved);
}
private void OnSimilarAdded(SimilarCollection similar)
{
similar.WordId = this.WordId;
}
private void OnSimilarRemoved(SimilarCollection similar)
{
similar.WordId = null;
}
}
[Table]
public class WordJunctionSimilar
{
[Column(IsPrimaryKey=true)]
public int WordId;
[Column(IsPrimaryKey=true)]
public int SimilarId;
private EntityRef<Word> wordRef;
[Association(Name="FK_Similar_Words0", Storage="wordRef",ThisKey="WordId",OtherKey="WordId")]
public Word WordRef
{
get { return wordRef.Entity; }
set { wordRef.Entity = value; WordId = value.WordId; }
}
public WordJunctionSimilar()
{
wordRef = new EntityRef<Word>();
}
}