C# Entity-Framework: How can I combine a .Find and .Include on a Model Object?

前端 未结 5 936
感情败类
感情败类 2020-11-27 11:36

I\'m doing the mvcmusicstore practice tutorial. I noticed something when creating the scaffold for the album manager (add delete edit).

I want to write code elegantl

5条回答
  •  余生分开走
    2020-11-27 12:24

    You have to cast IQueryable to DbSet

    var dbSet = (DbSet) db.Set().Include("");

    return dbSet.Find(id);

提交回复
热议问题