private void AppendFilter(object sender, RoutedEventArgs e) { PatientDbContext patientDbContext = new PatientDbContext(); string val = txtValue.Text; dataGrid.ItemsSource = patientDbContext .Patients .Where(i => i.FirstName.Contains(val) || i.LastName.Contains(val) || i.PatientId.Contains(val) || i.Title.Contains(val) && ( i.Created >= dtFromDate.DisplayDate && i.Created < dtFromDate.DisplayDate )).ToList(); patientDbContext.Dispose(); }