c# - Linq query returning duplicates -


So I have two data labels, both are derived from the ODBC data source rows for sale for one (estado = 'Vents') and the second Estado = 'XIST' (Database creates line pairs for each sale, indicates a sales information and indicates information about stock movements from the deposit amount of the second store Whether the store I have to meet each vantas line in the respective EXIST line ['Documents' ID field] and get the "Deposit amount" value from the existing row.)

I did this to do this question (ODBC driver I am using is not allowed to be included in it, so this is the best thing to do in Linux)

  DataTable dtResult = new DataTable (); DtResult.Columns.Add ("Documento", type64 (Int64)); DtResult.Columns.Add ("Fecha", typef (dated)); DtResult.Columns.Add ("Articulo", typef (string)); DtResult.Columns.Add ("Deposit", typef (string)); DtResult.Columns.Add ("ImpDMn", type (decimal)); DtResult.Columns.Add ("Cantidad", typef (decimal)); DtResult.Columns.Add ("Partida", typef (string)); Results above = VentasDT.AsEnumerable () in DataRows1 with // VentasDT Ventas data is included in DataRows2 in DataTable ExistDT.AsEnumerable () // ExistDT DataRows1.Field & Data on Data with LT is DataTable, Int64 & gt ; ("Documento") is equivalent to dataRows2.Field & LT; Int64 & gt; ("Documento") Select dtResult.LoadDataRow (New Item [] {dataRows1.Field & lt; Int64> ("Documento"), dataRows1.Field & LT; Date Time & gt; ("Fecha"), dataRows1 .field & lt; string & gt; ("death"), dataRows2.Field & lt; string & gt; ("deposito"), dataRows1.Field & lt; decimal & gt; ("impdmn"), dataRows1 Field & LT; Decimal & gt; ("Cantidad"), dataRows1.Field & LT; String & gt; ("Partida"), False); Result.CopyToDataTable ();   

And it works, but for some reasons it duplicates some lines I checked the rows that were repeated and they were similar to each other. Their document numbers are identical (and only one vantas and one document number is per EXIST row, which is also included for these duplicates), so I do not know why they are not being repetitive. I've checked the source datatables as well, and likewise, there is only one corresponding line for each duplicate. The EXIST table is larger than the VENTAS table (it also records the transfer between the stores which is not the sale), but the associated table is larger than either (though both are not as large as both)

  VENTAS: 85123 EXIST: 116857 Joined: 141287   

Is there something wrong with my query? Should I include some group by clauses or duststicks, or is this structure enough (as far as I have seen that a left link should be copied) enough?

due to one of the reasons that you have been involved in this "Deposito" From the field you can get the value of ExistDT , you can take place instead of joining a dictionary search. Here's how you can do it:

  Var depositoPorDocumento = ExistDT.AsEnumerable (). ToDictionary (dr = & gt; dr.field & lt; int64 & gt; ("documento"), dr = & gt; dr .field & lt; string & gt; ("depositor"); Voracity: ASAnimable ()) (Int64 id = Field & lt; Int64 & gt; ("Documento"); Submit the String; if (Document! For the depositors. Tryiget Value (ID, Deposited Deposit)) {release;} DtResult. LoadDataRow (new object [] {id, vr.Field & lt; date time & gt; ("Fecha"), vr.Field & lt; string & gt; ("death"), deposito, vr.field & lt; Decimal & gt; ("ImpDMn"), Vr.Field & lt; Decimal & gt; ("Cantidad"), V.R. Field  ("Partida"),}, False);} Result. CopyToDataTable ();    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

python - 'NoneType' object is not callable using 'find_all' in BeautifulSoup -