how to make a query that compares two data of a table in LinQ

0

Hello developers I have a problem turns out that I am doing an update in linQ and for it I have to compare two data so that the update is correct (since one of these data is repeated in my table) but it turns out that linq does not let me compare with & & amp; some idea of how to do it here is the code

var count = progSemanal.Where(w => w.Codigo_barra.ToString().ToLower() == codmodel.ToString().ToLower()) && progSemanal.Where(t => t.Fecha == DbFunctions.TruncateTime(f2)).Count();//Count para update cod barra

 if (count > 0)
 {//Actualiza }else // inserta

The error that appears is this I can not apply operand & & Iqueriable and int CodModel is a whole code and date is datetime format

    
asked by Joel Baez 30.04.2018 в 15:27
source

2 answers

1

The error is that you want to apply the & & & amp; after closing the parentsis of the method where

I really do not know what you want to do with your line of code, but if you want to apply the ampersand within your operation lamba you must include it within it.

 var count = progSemanal.Where(w => w.Codigo_barra.ToString().ToLower() == codmodel.ToString().ToLower() && w.Fecha == DbFunctions.TruncateTime(f2)).Count();//Count para update cod barra
    
answered by 30.04.2018 / 19:39
source
0

You can do it with two different lists that are equivalent to your tables being two variables so you can buy them in this way:

var primerTabla = Tabla1.ToList();
var segundaTabla = Tabla2.ToList();

var esDiferente =
        primerTabla.Zip(segundaTabla, (j, k) => j.itemNo == k.itemMo).Any(m => !m);
    
answered by 30.04.2018 в 15:49