Thursday, 12 September 2013

How to search multiple term in columns if that term not be empty and get only one page of rows?

How to search multiple term in columns if that term not be empty and get
only one page of rows?

I have to search field :name and email ;I want to let user to search with
these fields and if each of fields be empty,not search for that field.I
tried this LINQ to entity:
var result=new List<T>();
String tmp;
if(!String.IsNullOrEmpty(name.Text))
{
tmp=name.Text;
result=result.Concat(context.Where(u=>u.Name==tmp);
}
if(!String.IsNullOrEmpty(email.Text))
{
tmp=email.Text;
result=result.Concat(context.Where(u=>u.EMail==tmp);
}
var thisPageResult=result.Skip((page - 1) * perPage).Take(perPage);
but in this method;all of result will be stored in memory and then I get
thisPageResult from it.
How can I create above search to load only this page's result into
memory,not all result?

No comments:

Post a Comment