把Equals改成 ==的写法就可以了,
query = query.WhereIf(m => m.VendorId==search.VendorId, !string.IsNullOrEmpty(Convert.ToString(search.VendorId)));