Joining on multiple keys

suggest change
PropertyInfo[] stringProps = typeof (string).GetProperties(); // string properties
PropertyInfo[] builderProps = typeof(StringBuilder).GetProperties(); // stringbuilder properties

var query =
    from s in stringProps
    join b in builderProps
        on new { s.Name, s.PropertyType } equals new { b.Name, b.PropertyType }
    select new
    {
        s.Name,
        s.PropertyType,
        StringToken = s.MetadataToken,
        StringBuilderToken = b.MetadataToken
    };

The anonymous types in the join above must contain the same properties in the same order. Those objects are equal only if every property is equal. Otherwise the query does not compile.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents