Well you basically need the Expression<Func<YourModel, bool>>
. You build a filter to pass to EF. The below info is more than enough to get you started.
So imagine you have a class like the below. This can be any class not just a ViewModel.
public class Person
{
public int Id {get;set;}
public string Name {get;set;}
}
The expression would look sth like this.
Expression<Func<Person,bool>> predicate = p => p.Name == "Some name";
db.People.Where(predicate); // How you would use it in a db context
You can also view this link that uses LinqKit.You do not have to use LinqKit but has some nice examples http://www.albahari.com/nutshell/linqkit.aspx
I want to be able to filter table based on filled parameters in the view model.
Since you want the above you can append to your predicate
and just pass it to your Where,Any,Count...
as one.
You can see a lot of techniques to how to append to your filter here:
How to Append to an expression
My favorite way of appending is using linqkit predicate builder http://www.albahari.com/nutshell/predicatebuilder.aspx
In the above link many techniques are showcased including the predicate builder.