[LINQ]SELECT多個Column欄位

  • 6915
  • 0
  • 2016-12-01

摘要:[LINQ]SELECT多個Column欄位

public ActionResult Index()
{
	var model = from p in db.tableName
				where 1 == 1
				select new { p.empid,p.cname};
	return View(model);            
}

要客製化欄位名稱的話,這樣寫就可以囉
select new { new_empid = p.empid,new_cname = p.cname};