public ActionResult GetResult(int page, int limit, string ID, string Name)
{
//找到数据库中的表staffJob
//var list = from a in oSMS.Staff
// select a;
var list = from c in oSMS.Staff
join p in oSMS.Job
on c.JobId equals p.Id
select new { c, p };
if (!string.IsNullOrEmpty(ID))
{
list = list.Where(x => x.c.No.Contains(ID));
}
if (!string.IsNullOrEmpty(Name))
{
list = list.Where(x => x.c.Name.Contains(Name));
}
int offset = limit * (page - 1);
var data = list.OrderBy(x => x.c.Name).Skip(offset).Take(limit).ToList();
var json = new
{
code = 0,
msg = "",
count = list.ToList().Count,
data = data,
};
return Json(json, JsonRequestBehavior.AllowGet);
}