score:9
i believe this is what you are looking for
var innerjoin =
from rr1 in r1
join rr2 in r2 on new {rr1.month, rr1.id} equals new {rr2.month, rr2.id}
select new { r1 = rr1, r2 = rr2 };
the new anonymous object can be any type and has access to any properties that are available for the two collections being joined.
for a left outer join this is how it would be done
var leftjoin =
from rr1 in r1
join rr2 in r2 on new {rr1.month, rr1.id} equals new {rr2.month, rr2.id} into ps
from rr2 in ps.defaultifempty()
select new { r1 = rr1, r2 = rr2 };
score:-1
if you want to join two table with some same of one column fkid is same then used following code two join both table and access to get desired result otherwise ignore.
following db is the database entities object.
note: in your code you join different entities month and id are different in data that reason you get empty result used following code
var v = (from a in db.r1.tolist()
join b in db.r2.tolist() on a.month equals b.id
select new
{
id = a.id,
month = b.month // or a.month as you want,
values = a.values
});
by using these you access both table value and get accepted result. thank if it is usable for you.
score:3
this is the chain version of your query.
var delreport= r1.join(r2, l => l.id, r => r.id, (l, r) => new { lft = l, rght = r })
.where(x => x.lft.month == x.rght.month)
.select(_ => new{ _.rght.id, _.rght.month}).tolist();
it is tested and works with your data.
Source: stackoverflow.com
Related Query
- join two tables with multiple condition in linq
- Problem with simple join by multiple columns in two tables using linq
- linq join tables with multiple columns with or condition
- How to left join multiple tables with LINQ
- LINQ to SQL and Join two tables with OR clause
- using linq with join using two where on two tables
- linq join 3 tables with or condition
- LInq left join with multiple condition in on clause
- Entity Framework: How to perform left join with EF and LINQ among multiple tables
- Linq left join with multiple tables
- How to join two tables with Linq in an MVC controller
- Linq expression with multiple joins with condition in each join
- LINQ Group by on multiple tables with nested group by with join and aggregate
- Complex joins in Linq with multiple tables and LEFT OUTER JOIN
- Join two tables with one to many relationship and pick latest from multiple side
- how to join two tables with comma separated values column in c# linq asp.net mvc
- Linq left outer join with multiple condition
- Linq join on multiple tables with null values
- How can I make a JOIN query with LINQ between two tables (entities) with many-to-many relationship, while there is no joining table in EF?
- LINQ Left Outer Join Multiple Tables with Group Count and Row Concatenation
- C# Linq statement to join two tables and multiple columns
- Linq query with left join having multiple tables
- SQL to LINQ - multiple tables left outer join with where clause referring right table
- How to join a table to two other tables with linq in a complex query?
- Linq join on multpile columns with a where not equals condition and need to return columns from both tables
- Linq join condition with multipe data from two table
- LINQ to SQL multiple left join query with subquery at join condition
- how to join two tables where the condition 'Where' is related to a third table that is associated with the first table
- Left outer join with multiple where condition with LINQ giving null reference error
- How can I use this Linq Query using it with a multiple parameter by Join tables
More Query from same tag
- Nested GroupBy using Linq
- Linq Expression tree compiling non-trivial object constants and somehow referring to them
- How do you remove OrderBy expression from an ExpressionTree using a ExpressionVisitor?
- How to loop collections in LINQ and pass on data
- linq: how to divide a list into two by the sum of the values and keeping the input order
- Nested Linq query (multiple levels)
- C# LINQ: How to find IList<Peak>.Max?
- How to use Distinct option to filter the value of a Column Name that is related to different foreign Keys. C# .NET Lambda LINQ
- Turn SQL query which contains multiple join, left join, group by and having to EF core
- Conditional where with or criteria linqtosql
- Explain in small words why IQueryable<T> is needed
- Assign member variables from view model to query result
- Linq with transaction
- Nested Select in LINQ with Lambda Expression
- Performing an operation during enumeration
- I want to query a json file to find users with two or more tags in common
- What's the best way to write [0..100] in C#?
- Linq get distinct ordered elements without .GroupBy()
- Using into and from in Linq query
- Get items from List A where Id is common in both List A and List B and counter of that Id is more than 1 in List A or List B
- Retrieving contact information from partylist field in phonecall entity on create
- Select 2 elements with linq
- Linq-to-sql One-To-Many with a max
- Creating a generic xml linq search based on attribute name/value pairs
- Linq: get articles with top vote count
- Instantiating Immutable Objects With Reflection
- nest yields to return IEnumerable<IEnumerable<T>> with lazy evaluation
- Is there a better way to achieve this with Linq or a better code
- Multiple deletions using LINQ (more specifically Linq2Nhibernate, but...)
- C# lambda extract a single row string value