title: Dynamic Linq query for join two tables with more than one condition(dynamically)
body: <p>Condition will be specified at run time only</p>
  
  <p>I tried to inner join with two tables with one condition dynamically, It is working fine.
  but with two or more condition dynamically ,its not working.Please help me solve this problem</p>
  
  <p>Please see the cases</p>
  
  <p><strong>case 1:</strong> join with one condition (<strong>working fine</strong>)</p>
  
  <pre><code>Base entity:User
  
  entity to join :Role
  
  condition to join: Role.Id = User.RoleId
  
  
  //select * from User inner join Role on User.RoleId=Role.Id
  
  //static way
  
       IQueryable&lt;UserEntity&gt; query =
          db.Set&lt;user&gt;().Join(db.Set&lt;Role&gt;(), 
          user =&gt;  User.RoleId, 
          role=&gt; role.Id, 
          (user , role) =&gt; new { user , role }).Select(temp=&gt; temp.user);
  
  
  
  //Dynamic Way **(working fine)**           
  
  
   ParameterExpression lambdaExprVar_Role = Expression.Parameter(typeof(Role), "role");
  
              PropertyInfo rightPropertyInfo_role = typeof(Role).GetProperty("Id");
  
              Expression rightExpression_role = Expression.Property(lambdaExprVar_Role, rightPropertyInfo_role );
  
              Expression&lt;Func&lt;Role, Int64&gt;&gt; myexp_role = Expression.Lambda&lt;Func&lt;Role, Int64&gt;&gt;(rightExpression_role , new ParameterExpression[] { lambdaExprVar_Role });                  
  
              ParameterExpression lambdaExprVar_User = Expression.Parameter(typeof(User), "user");
  
              PropertyInfo rightPropertyInfo_user = typeof(User).GetProperty("RoleId");
  
              Expression rightExpression_user = Expression.Property(lambdaExprVar_User, rightPropertyInfo_user);
  
              Expression&lt;Func&lt;User, Int64&gt;&gt; myexp_user = Expression.Lambda&lt;Func&lt;User, Int64&gt;&gt;(rightExpression_user, new ParameterExpression[] { lambdaExprVar_User });       
  
      IQueryable&lt;OrganizationNode&gt; query = db.Set&lt;User&gt;()
                  .Join(db.Set&lt;Role&gt;(), myexp_user, myexp_role, (user, role) =&gt; new {user, role})
                  .Select(temp=&gt;temp.user);
  </code></pre>
  
  <p><strong>case 2:</strong> join with two condition(not working)</p>
  
  <pre><code>Base entity:User
  
  entity to join :Role
  
  condition to join: Role.Id==User.RoleId,Role.Code==User.RoleCode
  
  //select * from User inner join Role on User.RoleId=Role.Id and User.RoleCode=Role.Code
  
  //static way **(working fine)**
  
  
  
      IQueryable&lt;User&gt; query =
          db.Set&lt;user&gt;().Join(db.Set&lt;Role&gt;(), 
          **user =&gt; new { matchId = user.RoleId, matchcode= user.RoleCode}, 
          role=&gt; new { matchId = role.Id, matchcode= role.code},** 
          (user , role) =&gt; new { user , role }).Select(temp=&gt; temp.user);
  
  //Dynamic Way   (**** not working)  
  </code></pre>
  
  <p>Help me to write/rewrite the code.</p>