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 Articles
- 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
- LINQ to SQL: lambda expression vs .Where()
- IF condition in Linq
- Implement LINQ to SQL/Entity like behavior in custom object
- Splitting an Entity Framework linq query causes includes to not work
- Using a LINQ ExpressionVisitor to replace primitive parameters with property references in a lambda expression
- WebAPI .getJSON function and querying a list with linq returning "Undefined"
- Optimize result list using LINQ
- LinQ how to change a integer like 1 to string 001
- DataGridView AllowUserToAddRow property doesn't work
- DataGridView column names from object property values?
- How to use Future query Nhibernate in case of many to many association
- Editing the LINQ to SQL object model
- How to get flattened list from dictionary key query where values are lists?
- Convert SQL raw query into Linq
- SQL query to linq in mvc
- LINQ version of a SQL query
- How to group according to a field value
- Calling Enumerable.Join on a IEnumerable collection causes segmentation fault
- LINQ - Returning value of a property of an object that is not null
- What exactly is a circular reference?