私は次のクラスを持っています:
public class Question {
public Question() { this.Answers = new List<Answer>(); }
public int QuestionId { get; set; }
public string Text { get; set; }
public virtual ICollection<Answer> Answers { get; set; }
}
public class Answer {
public int AnswerId { get; set; }
public string Text { get; set; }
}
文字列をチェックしてエンディングを削除する方法として、誰かが提案した次のものがあります。これをメソッドに入れると、次のようになります。
public static string cleanQuestion(string text)
{
if (text == null) { return null; }
else {
return (Regex.Replace(text, "<p> </p>$", ""));
}
}
質問の Text フィールドでこのメソッドを呼び出す方法を知っています。しかし、各 Answer Text フィールドでメソッドを呼び出すにはどうすればよいでしょうか?