一些原因需要用到linq的多表联查,网上查了下资料,顺便整理了一下,包括了模糊查询,分页,排序字段。
话不多说,直接上代码
public List<ExamineUserEntity> GetUserExamineList(string username, string phone, int pageindex, int pagesize)
{
var query = (from exam in db.T_USEREXAMINE
join user in db.T_EXAMINE_USER
on exam.USERID equals user.ID
where (user.USERNAME.Contains(username) && exam.RECORDSTATUS == true && user.PHONE.Contains(phone))
orderby exam.CREATETIME
select new ExamineUserEntity { }
).Skip(pageindex * pagesize).Take(pagesize).ToList();
if (query != null)
{
return query;
}
else
{
return null;
}
}
时间: 2024-10-12 12:49:27