Small Change will do the trick
if (!String.IsNullOrEmpty(search))
{
query = query.Where(s => s.Name.Contains(search));
}
if (!String.IsNullOrEmpty(type))
{
query = query.Where(s => s.Type == type);
}
Filter data
- by (name) : type will be empty then only the filter by name apply
- or (type) : name will be empty then only the filter by type apply
- or (type and name) : both filters will apply
Note that I have changed your 2nd condition
if (!String.IsNullOrEmpty(search))
to
if (!String.IsNullOrEmpty(type))