Dynamic where Entity how to write ah??

 public List<NyUsers> Page(int pagesize, int pageindex, NyUsers model)
        {
            try
            {
              
                int skcount = (pageindex - 1) * pagesize;
                var db = new nanyouEntities();
                var query = xxx;

                if (string.IsNullOrEmpty(model.username))
                   query = xxx;

                IEnumerable<NyUsers> list = db.NyUsers.Where(m => query ).OrderByDescending(c => c.userid).Skip(skcount).Take(pagesize);
                return list.ToList();
            }
            catch (Exception ex)
            {
                throw ex.InnerException;
            }
        }


Here query I should how splicing ah???. . .

Started by Gladys at November 12, 2016 - 9:22 PM

int skcount = (pageindex - 1) * pagesize;
var db = new nanyouEntities();
var query = db.NyUsers.Where(m => m.xxx==model.xxx);
 
if (string.IsNullOrEmpty(model.username))
   query = query.Where(m => m.username==model.username);
 
IEnumerable<NyUsers> list = query.OrderByDescending(c => c.userid).Skip(skcount).Take(pagesize);
return list.ToList();

Posted by Pauline at November 19, 2016 - 10:08 PM

You where it SQL not written statement?

Posted by Bill at November 25, 2016 - 11:08 PM