score:1
This should do want you want:
var notInT2 = T1.Where(i => T2.All(e => e.T1ID != i.Id) &&
T2.All(e => e.PT1ID != i.Id));
To test it:
class RowT1 { public Int32 Id;}
class RowT2 { public Int32 T1ID; public Int32 PT1ID; }
class Programm
{
static void Main()
{
var T1 = new List<RowT1>(){new RowT1(){Id=1},
new RowT1(){Id=2},
new RowT1(){Id=3},
new RowT1(){Id=4}};
var T2 = new List<RowT2>(){new RowT2(){T1ID=2, PT1ID=1},
new RowT2(){T1ID=3, PT1ID=2}};
var notInT2 = T1.Where(i => T2.All(e => e.T1ID != i.Id) &&
T2.All(e => e.PT1ID != i.Id));
Console.ReadLine();
}
}
score:1
I'm not 100% clear what you are trying to do.
I assume that you want to return all rows from T1 and any matching rows from T2 where either the column T1ID or PT1ID values equal the T1 ID column.
If this is the case you need a outer join. You can get a good example of outer joins from the MSDN microsoft Forums
score:1
If your problem is to do an outer join : http://msdn.microsoft.com/en-us/library/bb399397.aspx
If your problem is to return differences : msdn.microsoft.com/en-us/library/bb386962.aspx
Source: stackoverflow.com
Related Query
- Left outer join using LINQ -- understanding the code
- LINQ Source Code Available
- How can I code an outer join using LINQ and EF6?
- Problem with simple join by multiple columns in two tables using linq
- creating Linq to sqlite dbml from DbLinq source code
- Linq to sql as object data source - designer problem with partial classes
- Problem with Linq Left Join
- Outer join in LINQ Problem
- join problem in linq
- Linq problem when trying a left join projection with multiple records
- source code for LINQ 101 samples
- Problem creating an Entity object/queryable from the result of a LINQ join in MVC
- LINQ Join query problem
- LINQ Right Outer Join Problem
- EntityFramework Core 6.0 Linq Group Join problem ( on "into" word)
- How to join one row to every row in source table using LINQ
- Linq join problem
- Linq Scope Problem + Reduce Repeated Code
- LINQ query complex join problem
- c# linq to sql join problem
- c# Linq or code to extract groups from a single list of source data
- LINQ - outer join to parent class in EF code first
- Convert sql code to linq (Inner join Query)
- linq join code doesn't work
- Why this multi linq join code does not work?
- LEFT OUTER JOIN in LINQ
- How do you perform a left outer join using linq extension methods
- Convert string[] to int[] in one line of code using LINQ
- How to do joins in LINQ on multiple fields in single join
- LINQ - Full Outer Join
More Query from same tag
- Group by Name Linq + C#
- Linq Full Outer Join Error
- Flattening a loop with lookups into a single linq expression
- WPF: Get column name from selected row
- Convert sql statement with two joined count subqueries to Linq-EF6 functions
- Check if List<T> element contains an item with a Particular Property Value
- How to merge two classes into single unit?
- How is join+into clause converted to GroupJoin
- How to overcome null exception when using Linq Count to sort a stringlist?
- Display only selected columns
- Deleting a User from a Conversation with Entity Framework
- How can I query a DbSet so that it returns both Local and non-Local data
- GroupBy loses ThenBy sort order
- Getting a percent Value using Linq with groups
- Parsing PHP page for an ios application using Linq and Html Agility Pack
- linq to xml
- How to get the sum of multiple columns of a datatable in c#
- "Sequence contains no matching element" C#
- LINQ to SQL Web Application Best Practices
- Passing an expression from a LINQ Queryable
- LINQ to XML - Nothing is binding?
- DeSerialize DataTable Row Collection into List<T>
- Ignore acutes in LINQ when using "Contains"
- SQL returns data but the corresponding Linq statement returns no data
- Foreach loop to Lambda or simpler LINQ query
- c# groupby orderby thenby Try specifying the type arguments explicitly
- Linq to entities join not working
- Getting Distinct Values with LINQ
- read null values and return null from a xml file C# win froms
- LINQ syntax vs SQL syntax