You could use the% lin_% co to know which ones are repeated
var result = from item in dbcontext.NombreTabla
group item by item.codigo into g
select new {
codigo = g.Key,
cantidad = g.Count(),
items = g
};
In this case you return all the codes and you can validate using the group by
if there are repeated
But if you need it you can also filter
var result = from item in dbcontext.NombreTabla
group item by item.codigo into g
where g.Count() > 1
select new {
codigo = g.Key,
items = g
};
to go through the list you would use
foreach(var codGroup in result){
//aqui puede acceder al codGroup.codigo, para conocer por cual esta agrupando
foreach(var item in codGroup.items){
//aqui puedes acceder a cada registro que tiene ese codigo
}
}
Group query results