我会推荐,你通过entityframeworktutorial工作。我很确定你的问题将在这里得到解答。
总之:在实体中,您将有一个DbContext
代表您的数据库。例如:
namespace EF_Code_First_Tutorials
{
public class SchoolContext: DbContext
{
public SchoolContext(): base()
{
}
public DbSet<Student> Students { get; set; }
public DbSet<Standard> Standards { get; set; }
}
}
DbSet<Student>
表示Student
表。要执行对表的查询,您可以使用Linq:
var student = dbCtx.Students.FirstOrDefault(student => studend.Name == "SomeName");
...
如上所述,我强烈建议通过entitiy教程进行操作。
对于你的问题,你可以使用:
var description = _dbObj.Disease.FirstOrDefault(disease => disease.ID == SomeId);
...
希望有所帮助。
我投票结束这个问题作为题外话,因为它要求代码没有显示足够的努力。 – grek40