EricGS
EricGS

Reputation: 1343

Index (zero based) must be greater than or equal to zero error

im geting the next error:

Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

and im not sure what it means, this is my code:

 var gruposA = db_cm.Permisos_Grupo_User.Include("Permisos_Grupo")
                            .Where(g => g.id_user == id && model.grupos.Any(x => int.Parse(x.Value) == g.id_grupo))
                            .ToList();

can someone tell me wath is wrong?

model.grupos is an IEnumerable<SelectListItem>

what i need to do is select a list of cm.Permisos_Grupo_User if the id is on model.grupos

Upvotes: 2

Views: 1167

Answers (1)

EricGS
EricGS

Reputation: 1343

well, adding a .ToList() fixed the problem

db_cm.Permisos_Grupo_User.Include("Permisos_Grupo").ToList()
                            .Where(g => g.id_user == id && model.grupos.Any(x => int.Parse(x.Value) == g.id_grupo))
                            .ToList();

Upvotes: 1

Related Questions