I'm using the Select2 plugin for searching on my table through LINQ. The issue I'm facing is the multi-select returns me an array and I get an error that I cant convert string[]
to string
. Here is my view:
<select class="js-example-basic-multiple"name="country[]" multiple="multiple">
<option value="">Select a country...</option>
<option value="AF">Afghanistan</option>
<option value="AX">Åland Islands</option>
<option value="AL">Albania</option>
</select>
I want on the controller to search records that I select from the dropdown. My controller is:
var model = from r in db.Clients
orderby r.DateRegister descending
where (r.DateRegister >= datepicker3 && r.DateRegister <= datepicker2 || datepicker2 == null || datepicker3 == null)
where r.Name.Contains(FirstName) || FirstName == "" || FirstName == null
where r.LastName.Contains(LastName) || LastName == "" || LastName == null
where r.Phone.Contains(Phone) || Phone == "" || Phone == null
where r.Email.Contains(Email) || Email == "" || Email == null
where r.PromoCode.Contains(PromoCode) || PromoCode == "" || PromoCode == null
where r.Brand.Contains(Brand) || Brand == "" || Brand == null
where r.Rentetiion == Retetion || Retetion == null
where r.SaleStatus == statos || statos == null
where r.Desk == desk || desk == null
where r.workerId == Broker || Broker == null
where r.Country.Contains(country)||country == null
Where country
will be more then 1 item to search.