MVC 知识点学习3(linq to sql)

1、通过DbContext对象的Database.SqlQuery执行sql语句

string query = "SELECT EnrollmentDate, COUNT(*) AS StudentCount "
+ "FROM Person "
+ "WHERE Discriminator = 'Student' "
+ "GROUP BY EnrollmentDate";
IEnumerable<EnrollmentDateGroup> data = db.Database.SqlQuery<EnrollmentDateGroup>(query);

return View(data.ToList());

上一篇:error: 'INT_MAX' was not declared in this scope


下一篇:Java基础05