Click here to Skip to main content
14,267,806 members
   

C#

 
AnswerRe: C# LINQ JOIN: Getting out of memory exception Pin
Mycroft Holmes5-Jul-19 13:28
memberMycroft Holmes5-Jul-19 13:28 
GeneralRe: C# LINQ JOIN: Getting out of memory exception Pin
Mou_kol8-Jul-19 5:53
memberMou_kol8-Jul-19 5:53 
GeneralRe: C# LINQ JOIN: Getting out of memory exception Pin
Dave Kreskowiak8-Jul-19 6:27
mveDave Kreskowiak8-Jul-19 6:27 
GeneralRe: C# LINQ JOIN: Getting out of memory exception Pin
Eddy Vluggen8-Jul-19 8:22
mveEddy Vluggen8-Jul-19 8:22 
GeneralRe: C# LINQ JOIN: Getting out of memory exception Pin
Gerry Schmitz8-Jul-19 10:50
mveGerry Schmitz8-Jul-19 10:50 
GeneralRe: C# LINQ JOIN: Getting out of memory exception Pin
Mycroft Holmes8-Jul-19 11:31
memberMycroft Holmes8-Jul-19 11:31 
AnswerRe: C# LINQ JOIN: Getting out of memory exception Pin
Dave Kreskowiak5-Jul-19 18:55
mveDave Kreskowiak5-Jul-19 18:55 
AnswerRe: C# LINQ JOIN: Getting out of memory exception Pin
lmoelleb9-Jul-19 22:42
memberlmoelleb9-Jul-19 22:42 
As others have stated, doing this in a database is probably better. Databases are not magic though. Set it up wrong (lack of indexes, asking it to join with queries written as bad in SQL as these are written in Linq) and it will be crazy slow.

If it isn't possible to use a database I would do load the second lists into a lookup (if multiple records can have the same key) or dictionary (if you are sure they are unique.

Now the first list can do a "manual" join. Assuming you used a lookup (use .ToLookup or load directly to your own ILookup implementation) it will be something like (just written from memory, you will need to adapt it):
from leftItem in list1
let discustingKey = CalculateYourUglyKey(leftItem)
where list2Lookup.ContainsKey(discustingKey)
from rightItem in list2Lookup[discustingKey]
select WhateverYouWantToCreateFromLeftAndRightItem(leftItem, rightItem)

Sorry, I can't say how to format it exactly so it gives you the current output, because frankly your code is so ugly I can't read it - but this should give you an idea on how to reduce your key calculation to once per item in each list.

Instead of using Linq to make the "kind of a join", you can even do it from within an XML reader as each element is read. Then only the second list and the result needs to be in memory at the same time.
GeneralRe: C# LINQ JOIN: Getting out of memory exception Pin
Mou_kol14-Jul-19 0:34
memberMou_kol14-Jul-19 0:34 
GeneralRe: C# LINQ JOIN: Getting out of memory exception Pin
lmoelleb14-Jul-19 10:41
memberlmoelleb14-Jul-19 10:41 
QuestionMouse delta Pin
MatrixRatrix4-Jul-19 0:14
memberMatrixRatrix4-Jul-19 0:14 
AnswerRe: Mouse delta Pin
BillWoodruff4-Jul-19 2:19
mveBillWoodruff4-Jul-19 2:19 
QuestionWPF MVVM Entity Framework(using code First Approach) Pin
Member 145206353-Jul-19 23:21
memberMember 145206353-Jul-19 23:21 
AnswerRe: WPF MVVM Entity Framework(using code First Approach) Pin
F-ES Sitecore3-Jul-19 23:28
mveF-ES Sitecore3-Jul-19 23:28 
GeneralRe: WPF MVVM Entity Framework(using code First Approach) Pin
Member 145206354-Jul-19 2:48
memberMember 145206354-Jul-19 2:48 
GeneralRe: WPF MVVM Entity Framework(using code First Approach) Pin
Gerry Schmitz4-Jul-19 7:36
mveGerry Schmitz4-Jul-19 7:36 
GeneralRe: WPF MVVM Entity Framework(using code First Approach) Pin
Mycroft Holmes4-Jul-19 13:01
memberMycroft Holmes4-Jul-19 13:01 
AnswerRe: WPF MVVM Entity Framework(using code First Approach) Pin
BillWoodruff4-Jul-19 2:22
mveBillWoodruff4-Jul-19 2:22 
Questionindex was out of bound of the array Pin
Derbz3-Jul-19 16:50
memberDerbz3-Jul-19 16:50 
AnswerRe: index was out of bound of the array Pin
phil.o3-Jul-19 17:26
mvephil.o3-Jul-19 17:26 
GeneralRe: index was out of bound of the array Pin
lmoelleb3-Jul-19 22:36
memberlmoelleb3-Jul-19 22:36 
AnswerRe: index was out of bound of the array Pin
OriginalGriff3-Jul-19 19:49
protectorOriginalGriff3-Jul-19 19:49 
AnswerRe: index was out of bound of the array Pin
bVagadishnu5-Jul-19 7:03
memberbVagadishnu5-Jul-19 7:03 
QuestionTrying to use VS2017 C# and Excel2007. I need help understanding the error being reported Pin
Greg Gonzales2-Jul-19 19:15
memberGreg Gonzales2-Jul-19 19:15 
AnswerRe: Trying to use VS2017 C# and Excel2007. I need help understanding the error being reported Pin
OriginalGriff2-Jul-19 20:17
protectorOriginalGriff2-Jul-19 20:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.