I have a list typed in C # and I need to look up an item through multiple filters. Proving codes:
List<LoteRecla> listLoteRecla = new List<LoteRecla>();
I tried to use the .Exists () method by filtering only one field from this list, as below and worked normally.
if (!listLoteRecla.Exists(x => x.est_lote.Equals(dtDados.Rows[i]["est_lote"].ToString())))
But I was asked to use more filters, I tried to do the following:
if (!listLoteRecla.Exists(
x => x.est_lote.Equals(dtDados.Rows[i]["est_lote"].ToString()) &&
x.id_log_unidade.Equals(dtDados.Rows[i]["id_log_unidade"]) &&
x.id_log_unid_local.Equals(dtDados.Rows[i]["id_log_unid_local"]) &&
x.loc_rua.Equals(dtDados.Rows[i]["loc_rua"]) &&
x.loc_num.Equals(dtDados.Rows[i]["loc_num"].ToString()) &&
x.loc_altura.Equals(dtDados.Rows[i]["loc_altura"].ToString()) &&
x.id_log_produto.Equals(dtDados.Rows[i]["id_log_produto"]) &&
x.id_log_produto_emb.Equals(dtDados.Rows[i]["id_log_produto_emb"])))
{
But this way it is not working, I go through the same data and should not enter the IF, but it is coming in.
Am I doing something wrong? Is there any other way to do this that I need?
Thank you.