My question is if there is any difference in speed between this query
query.Where(i => (i.FirstName.Contains(firstname) || string.IsNullOrEmpty(firstname)) &&
(i.LastName.Contains(secondname) || string.IsNullOrEmpty(secondname)) &&
(i.DateOfOrder == date || date == default(DateTime)));
and this code:
if (!String.IsNullOrEmpty(firstname))
{
query = query.Where(i => i.FirstName.Contains(firstname));
}
if (!String.IsNullOrEmpty(secondname))
{
query = query.Where(i => i.FirstName.Contains(firstname));
}
if (date!=default(DateTime))
{
query = query.Where(i => i.DateOfOrder==date);
}
Edited, thanks for the answers.