Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>AFAIK you can only join this way:</p> <pre><code>var query = from obj_i in set1 join obj_j in set2 on new { JoinProperty1 = obj_i.SomeField1, JoinProperty2 = obj_i.SomeField2, JoinProperty3 = obj_i.SomeField3, JoinProperty4 = obj_i.SomeField4 } equals new { JoinProperty1 = obj_j.SomeOtherField1, JoinProperty2 = obj_j.SomeOtherField2, JoinProperty3 = obj_j.SomeOtherField3, JoinProperty4 = obj_j.SomeOtherField4 } </code></pre> <p><strong>The main requirements are: Property names, types and order in the anonymous objects your'e joining on must match.</strong></p> <p>You CAN'T use ANDs ORs etc. in joins. Just object1 equals object2.</p> <p>More advanced stuff in this LinqPad example:</p> <pre><code>class c1 { public int someIntField; public string someStringField; } class c2 { public Int64 someInt64Property {get;set;} private object someField; public string someStringFunction(){return someField.ToString();} } void Main() { var set1 = new List&lt;c1&gt;(); var set2 = new List&lt;c2&gt;(); var query = from obj_i in set1 join obj_j in set2 on new { JoinProperty1 = (Int64) obj_i.someIntField, JoinProperty2 = obj_i.someStringField } equals new { JoinProperty1 = obj_j.someInt64Property, JoinProperty2 = obj_j.someStringFunction() } select new {obj1 = obj_i, obj2 = obj_j}; } </code></pre> <p>Addressing names and property order is straightforward, addressing types can be achieved via casting/converting/parsing/calling methods etc. This might not always work with LINQ to EF or SQL or NHibernate, most method calls definitely won't work and will fail at run-time, so YMMV. This is because they are copied to public read-only properties in the anonymous objects, so as long as your expression produces values of correct type the join property - you should be fine.</p>
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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