Hi dharmendr, Suppose My SQL Query is like this -
SqlConnection conn = new SqlConnection(strConnectionString);
string strQuery = "Select * from Customer where";
if(strMobNo != string.Empty)
{
strQuery += " CustMobNo = '"+strMobNo+"' and ";
}
if(strName != string.Empty)
{
strQuery += " CustName LIKE '%" + strName + "%' and ";
}
if(strCity != string.Empty)
{
strQuery += " CustCity = '" + strCity + "' and ";
}
strQuery += " IsDeleted = 0;";
SqlCommand cmd = new SqlCommand(strQuery, conn);
conn.Open();
SqlDataReader rdr = cmd.ExecuteReader();
In the same way I want to build the LINQ Query. Like if Varibale has the value then consider it in the where clause otherwise not.