Query LINQ Dataset in Datagridview repeated rows

0

1. I have a query in LINQ (VB.NET):

Dim Consulta = From ConsultaEmisor In Emisor
               From ConsultaReceptor In Receptor
               From ConsultaComprobante In Comprobante
               Select New With {Mis campos}

2. I fill a grid with the query:

Datagridview1.datasource = Consulta.toList

3 . The query is inside a FOR because I fill my dataset by means of xmls: (In this case only 2)

For cont As Integer = 0 To lista - 1
   Dim PathFile As String = ("D:\XML SAT\" & ListBox1.SelectedItem & "\" & ListBox2.Items(cont))
   ds.ReadXml(PathFile)

4 . When the data is displayed on the grid in the first round a row is added (It takes the data of my dataset by means of the query LINQ to unite the nodes (datable) of the XML), everything well up there, but in the second round it duplicates them by the amount of "from" that I have in my Consultation, which in this case are 3 From (Issuer, Receiver and Proof)

5 . I can not use a join since no table has a field that I can relate as a primary key.

6 . Does anyone know a way other than the merge method to put my datatable on the grid?

The traditional way is

Datagridview1.datasource = dataset.tables("Tabla1")
Datagridview1.datasource = dataset.tables("Tabla2")
Datagridview1.datasource = dataset.tables("Tabla3")

But the Grid will only fill its columns with the last table that is assigned to the source ...

Already been a long time in this someone could help me?

Greetings!

    
asked by Diego Cantú 27.03.2016 в 11:31
source

1 answer

0

I already do it with a join using LINQ

It turns out that the xml had a field in common in each of its nodes called

"comprobante_Id"

was unaware of the existence of this field because when opening the xml this is not visible and I do not understand why

I found out about it by mistake .. trying to implement a code, I sent a message that told me that there was already a field called comprobante_Id I made a select with LINQ to each of the 3 tables bringing the field and it turned out that if it existed then I made the corresponding join for uni everything, it was very stressful to try to do something that Leandro says is not possible at least without using any of those methods, what they could explain to me is how to see all the hidden fields that an xml has, I think there is something of the scheme .. but I do not know how to handle it.

Greetings!

    
answered by 28.03.2016 / 18:24
source