Http://social.msdn.microsoft.com/Forums/en-US/linqtosql/thread/4482b083-72bd-4415-82be-8cccbd9eabba
Public Static Iqueryable join ( This Iqueryable outer, ienumerable inner, String Outerselector, String Innerselector, String Resultsselector, Params Object [] Values)
{
If (Inner = Null ) Throw New Argumentnullexception ( " Inner " );
If (Outerselector = Null ) Throw New Argumentnullexception ( " Outerselector " );
If (Innerselector = Null ) Throw New Argumentnullexception ( " Innerselector " );
If (Resultsselector = Null ) Throw New Argumentnullexception ( " Resultsselctor " );
Lambdaexpression outerselectorlambda=Dynamicexpression. parselamtype (outer. elementtype,Null, Outerselector, values );
Lambdaexpression innerselectorlambda=Dynamicexpression. parselamner (inner. asqueryable (). elementtype,Null, Innerselector, values );
Parameterexpression [] Parameters = New Parameterexpression [] {
Expression. parameter (outer. elementtype, " Outer " ), Expression. parameter (inner. asqueryable (). elementtype, " Inner " )};
Lambdaexpression resultsselectorlambda = Dynamicexpression. parselamters (parameters, Null , Resultsselector, values );
Return Outer. provider. createquery (
Expression. Call (
Typeof (Queryable ), " Join " ,
New Type [] {outer. elementtype, inner. asqueryable (). elementtype, outerselectorlambda. Body. type, resultsselectorlambda. Body. Type },
Outer. expression, inner. asqueryable (). Expression, expression. Quote (outerselectorlambda), expression. Quote (innerselectorlambda), expression. Quote (resultsselectorlambda )));
}
// The generic overload.
Public Static Iqueryable < T > Join < T > ( This Iqueryable < T > Outer, ienumerable < T > Inner, String Outerselector, String Innerselector, String Resultsselector, Params Object [] Values)
{
Return (Iqueryable < T > ) Join (iqueryable) Outer, (ienumerable) Inner, outerselector, innerselector, resultsselector, values );
}
Application
VaR aaa = Context. dict. Where (P => P. dictionaryid > 3 ). Select (P => P. dictionaryid );
VaR bbb=Context. dict. Join (AAA,"Dictionaryid","It","Outer");