私はサンプル文を記述するためにこのクラスを使用します。List <string>ではなくSampleSentenceを必要とするオブジェクトにList <string>を追加するにはどうすればよいですか?
public class SampleSentence
{
public int SampleSentenceId { get; set; } // SampleSentenceId (Primary key)
public int WordFormId { get; set; } // WordFormId
public string Text { get; set; } // Text
public int SourceId { get; set; } // SourceId
public int StatusId { get; set; } // StatusId
// Foreign keys
public virtual WordForm WordForm { get; set; } // FK_SampleSentenceWordForm
public SampleSentence()
{
SourceId = 1;
StatusId = 1;
}
}
とSampleSentences WordFormsの一部です:
public class WordForm
{
public int WordFormId { get; set; } // WordFormId (Primary key)
public int WordId { get; set; } // WordId
public string Definition { get; set; } // Definition (length: 200)
public int PosId { get; set; } // PosId
public int SourceId { get; set; } // SourceId
public int StatusId { get; set; } // StatusId
// Reverse navigation
public virtual System.Collections.Generic.ICollection<SampleSentence> SampleSentences { get; set; } // SampleSentence.FK_SampleSentenceWordForm
public virtual System.Collections.Generic.ICollection<Synonym> Synonyms { get; set; } // Synonym.FK_SynonymWordForm
// Foreign keys
public virtual Pos Pos { get; set; } // FK_WordFormPos
public virtual Word Word { get; set; } // FK_WordFormWord
public WordForm()
{
SourceId = 1;
StatusId = 1;
SampleSentences = new System.Collections.Generic.List<SampleSentence>();
Synonyms = new System.Collections.Generic.List<Synonym>();
}
}
私はこのような新しいWordFromを作成する方法を知っている:
var wordForm = new WordForm()
{
WordId = word.WordId,
Definition = result.definition,
SampleSentences = sampleSentences
PosId = pos
};
しかし、私のSampleSentencesはこのようにしていることを考える:
List<string> = sampleSentences
Ho w wordFormにsampleSentencesを追加できますか?
あなたは 'リストを変換する必要があります'を' ICollection 'に追加しましたか?どのように文字列を「文章」に変換すべきかを知っているべきですか?リスト内のこれらの文字列は 'SampleSentenceId'を参照していますか?それでは 'List 'をうまく使うべきでしょうか? –
HimBromBeere