Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>if i'm understanding right you want to do something like this:</p> <pre><code>internal class Db { public Db() { var parts = new List&lt;Part&gt; { new Part() {PartId = 1, PartName = "Part 1"}, new Part() {PartId = 2, PartName = "Part 2"}, }; Parts = parts.AsQueryable(); var carParts = new List&lt;CarPart&gt; { new CarPart() {CarPartId = 1, CarPartName = "Car Part 1.1", PartId = 1}, new CarPart() {CarPartId = 1, CarPartName = "Car Part 1.2", PartId = 1}, new CarPart() {CarPartId = 1, CarPartName = "Car Part 2.1", PartId = 2}, }; CarParts = carParts.AsQueryable(); } public IQueryable&lt;Part&gt; Parts { get; set; } public IQueryable&lt;CarPart&gt; CarParts { get; set; } } internal class CarPart { public int CarPartId { get; set; } public string CarPartName { get; set; } public int PartId { get; set; } } internal class Part { public int PartId { get; set; } public string PartName { get; set; } } static void Main(string[] args) { Db db = new Db(); var result = from carPart in db.CarParts join part in db.Parts on carPart.PartId equals part.PartId select new {Part = part, CarPart = carPart}; var lambdaResult = db.CarParts.Join(db.Parts, part =&gt; part.PartId, caPart =&gt; caPart.PartId, (carPart, part) =&gt; new {CarPart = carPart, Part = part}); foreach (var item in result) { Console.WriteLine(item.Part.PartName); Console.WriteLine(item.CarPart.CarPartName); } Console.WriteLine("------------"); foreach (var item in lambdaResult) { Console.WriteLine(item.Part.PartName); Console.WriteLine(item.CarPart.CarPartName); } } </code></pre> <p>the result is a new anonymous object with the joined objects as content. it would print this to the console:</p> <pre><code>Part 1 Car Part 1.1 Part 1 Car Part 1.2 Part 2 Car Part 2.1 ------- Part 1 Car Part 1.1 Part 1 Car Part 1.2 Part 2 Car Part 2.1 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload