RE: Linq Query



Please go to http://www.a2zdotnet.com/Default.aspx
for step by step tutorials for beginers in LINQ sections.

--
regards,
Pankaj
http://www.A2ZDotNet.com


"shapper" wrote:

Hello,

I have two Lists:

A = {ID, Name} = { (Null, John), (Null, Mary), (Null, Andrew), (Null,
Peter) }

B = {ID, Name} = { (1, John), (2, Robert), (3, Angela), (4, Andrew) }

I want to find which items in A do not exist in B then:

1. Add the items to B and using an ID from the function GetID(). B
would become:

B = {ID, Name} = { (1, John), (2, Robert), (3, Angela), (4,
Andrew), (231, Mary), (45, Peter) }

2. Then update the A list, or create a new one (C), to get the created
items:

C = {ID, Name} = { (231, Mary), (45, Peter) }

How can I do this with LINQ?

I have been trying a join but with the something as "not equals" but
it does not work.

I think I might need to do this in 3 steps:

1. Get items in B that do not exist in C;
2. Insert those items in C;
3. Get those items again from C to get the created ID's with the
correspondent names.

Could someone help me out with this?

Thanks,
Miguel





.



Relevant Pages

  • Re: Compare methods
    ... Linq - Sort = -8863 ... I didn't know what it was so I thought "Sorting should be simple + quick" and went for that instead. ... The execution of the Sort version is dominated in time by the sorting itself, which has to happen for both lists, always. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: China Travel Discussion List
    ... further split it into country specific lists. ... Peter spent his time answering questions about China here. ... Peter's list has no archives and Peter heavily "moderates" that list. ... I suspect I shan't be alone in ignoring this suggestion and posting ...
    (rec.travel.asia)
  • Re: [SLE] 9.3 is slow :( partial solved
    ... On Sunday 7 August 2005 18:28, Randall R Schulz wrote: ... If SuSE tries to win the desktop (As they told during the ... also follow several Redhat related lists, ... >> Peter M. Groen ...
    (SuSE)
  • Re: LINQ-Wrapper-Klassen an Controls binden?
    ... Peter Fleischer schrieb: ... Schau dir mal mit dem Profiler an der Datenbank an, was beispielsweise passiert, wenn eine LinQ auf das Ergebnis einer anderen LinQ abgesetzt wird, beispielsweise so: ... Dim dc As New DataClasses1DataContext ...
    (microsoft.public.de.german.entwickler.dotnet.datenbank)
  • Re: Bring over non-"" values
    ... I appreciate the reply Peter, I'll give it a shot tomorrow at work. ... > lists only the ... >>many many more columns of blanks ... > Dim rng As Range ...
    (microsoft.public.excel.worksheet.functions)