How do I connect to a database and loop over a recordset in C#?

前端 未结 8 2202
孤独总比滥情好
孤独总比滥情好 2021-01-03 17:44

What\'s the simplest way to connect and query a database for a set of records in C#?

8条回答
  •  旧巷少年郎
    2021-01-03 18:21

    I guess, you can try entity framework.

    using (SchoolDBEntities ctx = new SchoolDBEntities())
    {
         IList courseList = ctx.GetCoursesByStudentId(1).ToList();
         //do something with courselist here
    }
    

提交回复
热议问题