Frage zu LINQ to DataTable
Hallo @all,
bin leider mit LINQ auf Kriegsfuß, daher folgende Frage an die LINQ-Profis:
Ich habe ein LINQ Statement (das Funktioniert) :
Leider fehlt mir die Methode in<txtBasis> um es in eine DataView oder DataTable umzuwandeln.
Wie z.Bsp.
Die Assembly System.Data.DataSetExtensions.dll ist eingebunden.
Wie bekomme ich nun <txtBasis> in eine DataTable/DataView ohne die seq, in einer For-Each-Schleife reinzuschreiben ?
Kann mir da jemand helfen ?
Danke im Voraus
Frank
bin leider mit LINQ auf Kriegsfuß, daher folgende Frage an die LINQ-Profis:
Ich habe ein LINQ Statement (das Funktioniert) :
Dim txtBasis = From tbl In myPBtbl
Join dbKdInfos In myPBConv_KdDaten On tbl(4) Equals dbKdInfos(0) And tbl(1) Equals dbKdInfos(1)
Join dbPrInfos In myPBConv_Produkte On dbKdInfos(2) Equals dbPrInfos(0) And tbl(10) Equals dbPrInfos(1)
Select New With {.quelle = tbl(0), .jahr = Strings.Right(tbl(8), 4), .debitor = tbl(1), .frankierlizenz = tbl(4),
.produkt = tbl(10), .Anzahl = 1, .barcode = tbl(9), .Dispatch = Strings.Right(tbl(8), 10),
.GlobeId = dbKdInfos(2), .EndKunde = dbKdInfos(3), .zusatzl = tbl(16), .gewichtsrange = tbl(12),
.GlobeProdukt = dbPrInfos(2), .OfferID = dbPrInfos(4), .OfferPos = dbPrInfos(5), .produktpreis = dbPrInfos(6), .gewicht = tbl(20),
.charge = dbPrInfos(7), .chargedescript = dbPrInfos(8) }
Wie z.Bsp.
Dim _tbl As DataTable = txtBasis.CopyToDataTable()
Dim _vw As Dataview = txtBasis.AsDataView()
Wie bekomme ich nun <txtBasis> in eine DataTable/DataView ohne die seq, in einer For-Each-Schleife reinzuschreiben ?
Kann mir da jemand helfen ?
Danke im Voraus
Frank
Please also mark the comments that contributed to the solution of the article
Content-Key: 2825381645
Url: https://administrator.de/contentid/2825381645
Printed on: December 9, 2023 at 07:12 o'clock
2 Comments
Latest comment
Servus,
du hast die Variable "txtBasis" ohne Typ deklariert, damit du die Methode CopyToDataTable bekommst musst du die Variable auch mit dem enstprechenden Typ deklarieren, also bspw.
Zusätzlich im LINQ AsEnumerable() ans Dataset anhängen.
Siehe
https://stackoverflow.com/questions/4460654/best-practice-convert-linq-q ...
https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/creating-a ...
Grüße Uwe
du hast die Variable "txtBasis" ohne Typ deklariert, damit du die Methode CopyToDataTable bekommst musst du die Variable auch mit dem enstprechenden Typ deklarieren, also bspw.
Dim query As IEnumerable(Of DataRow) = From tbl ......................
Siehe
https://stackoverflow.com/questions/4460654/best-practice-convert-linq-q ...
https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/creating-a ...
Grüße Uwe