Error in Enumerable.Except method of LinQ

0

I have the following code:

var vistaRecibos = (from r in ctx.RECIBOSPAGO_DETALLE_GENERAL
                                  select new
                                  {
                                      r.idrecibopago,
                                  });

                var vistaAsientos = (from a in ctx.ASIENTO_CONTABLE
                                  select new
                                  {
                                      a.idrecibopago,
                                  });

                vistaRecibos = vistaRecibos.Except(vistaAsientos);

Which gives me error:

  

Error 71 The type arguments for the 'System.Linq.Enumerable.Except (System.Collections.Generic.IEnumerable, System.Collections.Generic.IEnumerable)' method can not be inferred from use. Try to specify the type arguments explicitly. C: \ Users \ German \ Desktop \ SAM Administrative \ Leon \ SAM1 \ Accounting \ frmExportAsientosContables.cs 461 36 sammayorazgo

I have used this comparison in other solutions and it does not mark me as an error (even the extra comma does not cause conflicts, and if I remove it, the problem continues).

Does anyone know how to fix it?

    
asked by German AT 27.03.2017 в 21:11
source

1 answer

1

Simplify your lines this way

var vistaRecibos = from r in ctx.RECIBOSPAGO_DETALLE_GENERAL
                                  select r.idrecibopago;

var vistaAsientos = from a in ctx.ASIENTO_CONTABLE
                                  select a.idrecibopago;

vistaRecibos = vistaRecibos.Except(vistaAsientos);

It is not necessary to add the word new {} that you would need if you were mapping to another type of data.

    
answered by 27.03.2017 / 21:19
source