That such a friend I turn to you again to solve a problem that I think is simple but I could not find the solution.
1- I am using the sew component to be able to enter various data into a search form that contains 2 dropdownlist.
2.- the 2 dropdownlists may be full or, if applicable, only one of the 2
3.- The model I use is the following
[NotMapped]
public class SearchProcedimiento:MtoProcedimiento
{
public int? Page { get; set; }
public IPagedList<MtoProcedimiento> result_MtoProcedimientos { get; set; }
public IEnumerable<MtoProcedimiento> ListProcedimientos { get; set; }
public int[] itemLicitaciones { get; set; }
public IEnumerable<MtoTipoEvento> ListTipoEventos { get; set; }
public int[] itemTipoEventos { get; set; }
}
The problem begins when I ask the controller in the following way.
var list = from t in db.MtoProcedures
where (model.itemLicitaciones.Contains ((int) t.MtoProcedimientoId) ||
model.itemTypeEvents.Contains ((int) t.MtoTipoEventoId))
select t;
Well it turns out that when the 2 dropdownlists are full it makes the query, but when one of the 2 is empty it sends me the following error.
No se puede crear un valor de constante NULL de tipo 'System.Int32[]'. Solo se admiten tipos de entidad, tipos de enumeración o tipos primitivos en este contexto.
I think it's because, the array is null, as it could validate to be able in case the array is empty put in the 0 position of the array the value "0" so that it considers all the records in my query.
or you could give me a help on how to generate this query.
Thank you very much greetings.