通知をモデル化する方法を理解しようとしています。これは私が試したものです。
public class NotificationType
{
public int NotificationTypeID { get; set; }
public string Type { get; set; }
public string Action { get; set; }
}
public class Notification
{
public int NotificationID { get; set; }
public bool ReadStatus { get; set; }
public DateTime DateCreated { get; set; }
[ForeignKey("User")]
public int UserID { get; set; }
[ForeignKey("NotificationType")]
public int NotificationTypeID { get; set; }
public int CommentID { get; set; }
public int ProjectID { get; set; }
public Comment Comment { get; set; }
public Project Project { get; set; }
public NotificationType NotificationType { get; set; }
public User User { get; set; }
}
率直に言って、私はまだ自分が何をしているのか分かりませんが、私が何をしようとしていたかを教えてください。それが悪い考えなら教えてください。
、および- に関連してNotifications
発生するアクション用のものがあります。そのため、これらすべてのナビゲーション プロパティとフィールドがあります。基本的に を使用してそれが何であるかを判断し、適切な ID フィールドを使用して情報を取得し、ユーザーに通知を表示したいと考えています。Comment
Reply
Project
NotificationType
最初の問題は、これらの ID ( ) フィールドを Nullable にすることができないように見えるため、CommentID
ProjectID
常にそれらを持つ必要があるとは限りません。
データ注釈や流暢なAPIを使用してnull可能にする方法、またはモデルをより適切に設計するにはどうすればよいですか?