EF
1)简单查询
后台代码
1 using MvcApplication18.Models; 2 using System; 3 using System.Collections.Generic; 4 using System.Data.SqlClient; 5 using System.Linq; 6 using System.Web; 7 using System.Web.Mvc; 8 9 namespace MvcApplication18.Controllers 10 { 11 public class HomeController : Controller 12 { 13 // 14 // GET: /Home/ 15 appDBEntities db = new appDBEntities(); 16 public ActionResult Index() 17 { 18 SqlParameter[] parameter = { }; 19 List<SecondHand_info> list = db.Database.SqlQuery<SecondHand_info>("select * from SecondHand_info where SecondHand_keyID >88", parameter).ToList(); 20 ViewData["list"] = list; 21 return View(); 22 } 23 24 } 25 }