ここには、エラーをスローするUser
テーブルを含めるのに使用しているラムダ式があります。派生モデルを含む関連クラス
ICollection<Activity> activity = db.Activities
.Include(i => i.Project.ProjectDoc.OfType<Cover>().Select(v => v.User))
.Where(u => u.UserID == WebSecurity.CurrentUserId)
.OrderByDescending(d => d.DateCreated).ToList();
includeステートメントのは、このエラー
インクルードパス式が タイプに定義されたナビゲーションプロパティを参照する必要がありますになります。参照ナビゲーションプロパティには点線のパスを使用し、コレクションナビゲーションプロパティには オペレータを選択します。
質問
public abstract class ProjectDoc
{
public int ProjectDocID { get; set; }
public int ProjectID { get; set; }
public string DocTitle { get; set; }
public string Status { get; set; }
public string Access { get; set; }
public DateTime DateCreated { get; set; }
public virtual ProjectDocAccess ProjectDocAccess { get; set; }
public virtual Project Project { get; set; }
public virtual ICollection<Comment> Comment { get; set; }
public ICollection<ProjectDocVote> ProjectDocVote { get; set; }
}
public class Segment : ProjectDoc
{
public string Content { get; set; }
}
public class Cover : ProjectDoc
{
public string CoverURL { get; set; }
public int UserID { get; set; }
public User User { get; set; }
}
でモデルどのように私はタイプCover
のProjectDoc
ためUser
テーブルが含まれていますか?
更新: 回答ごとに。 Cover
のモデルを次のように更新し、エラーの原因となっていたインクルードを削除しました。私は今データを得ることができます:
public class Cover : ProjectDoc
{
public string CoverURL { get; set; }
public int UserID { get; set; }
public virtual User User { get; set; }
}