Joining on multiple keys
suggest changePropertyInfo[] 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.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents