Hi,
You can Achieve the task by doing two steps
1. Pass Default Value to unused Filter Parameter
2. In SQL query you can easily make OR Condition to skip particular filter
Scenario :
Form UI(User Interface) , you searched by Due Date then Function Parameter Must be
Function Parameters
_CustomerID = 0 ; _BillTypeID =0 ; _DueDate='2014-01-01'
Form UI(User Interface) , you searched by CustomerID and Bill Type ID then Function Parameter Must be
Function Parameters
_CustomerID = 5 ; _BillTypeID =115 ; _DueDate=''
Linq Code Will Be
EmployeeDataContext objDB = new EmployeeDataContext();
int CustomerID = 0;
int BillID = 0;
string DueDate = "";
var res = from item in objDB.tblBills where((item.BillID== BillID || BillID == 0) && (item.CustomerID==CustomerID || CustomerID ==0) && (DueDate=="" || Convert.ToDateTime(DueDate)==item.DueDate)) select item;
Query will be
Select * from tblBill where
(CustomerID = _CustomerID or _CustomerID = 0) and
(BillTypeID = _BillTypeID or _BillTypeID = 0 )and
(_DueDate ='' or DueDate= Convert(date,_DueDate) )
Thank You,
Siva Rm K