Can I compare two lists in vb .net? [closed]

-1

When loading my form, I bring information from the database and insert it in a list, through a timer I go to consult possible changes, it is possible to compare the two lists to determine the changes included if it increases or decreases the size and to be able to know what items were changed ..

Private Sub Pedidos_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    ModRestaurante.Restaurant.CreaGrupoMesero(Me.BarraNavegacionPedidos)
    Dim sql As String = "SELECT Mesero FROM RE_MESAS ORDER BY Mesero ASC"
    Dim dt As DataTable = AbrirTabla(Conexion, sql)
    For i = 0 To dt.Rows.Count - 1
        listaMeseroInMesas.Add(dt.Rows(i).ToString)
    Next
End Sub

In the timer

  Dim sql As String = "SELECT Mesero FROM RE_MESAS ORDER BY Mesero ASC"
  Dim dt As DataTable = SMT_AbrirTabla(Conexion, sql)
  Dim NuevaLista As New List(Of String)
  For i = 0 To dt.Rows.Count - 1
      NuevaLista.Add(dt.Rows(i).ToString)
  Next
  'Aqui iria la comparación ?
    
asked by avargasma 22.11.2016 в 22:42
source

1 answer

3

There is a way to know which elements are in one collection and not in another ..

The code to do it would be something like this:

Dim SoloEnLaPrimeraColeccion As List(Of String) = Coleccion1.Except(Coleccion2).ToList()

For more examples you can look here:

link

    
answered by 23.11.2016 в 00:22