title: c# convert predicate between each other
body: <p>I'm developing and multi-tier application solution and my solution looks like this
  <br/></p>
  
  <ul>
  <li>Business.DomainObject</li>
  <li>Business.Process  (* Actual business layer)</li>
  <li>Data.Mapper</li>
  <li>Data.Repository</li>
  <li>Data.Sql.Entity  (* Actual data layer that has .dbml file)</li>
  </ul>
  
  <p>My <strong>Business.Process</strong> project (business layer) is only knows <strong>Business.DomainObject</strong> and <strong>Data.Repository</strong> projects, so doesn't know and not in relationship with Data.Sql.Entity project<br>
  I'm sending business (domain) objects to repository and do mapping inside this project, then I'm doing CRUD process inside repository layer with relationship data layers.</p>
  
  <p>My traditional domain object is like this, it has only properties <br/></p>
  
  <pre><code>public class UserBO
  {
  public string Email { get; set; }
  public string Username { get; set; }
  public string Password { get; set; }
  }
  </code></pre>
  
  <p>My business layer class is like this,</p>
  
  <pre><code>Repository r = new UserRepository();
  r.Insert(myUserDomainObject);
  </code></pre>
  
  <p><br/>
  Everything is OK, but I have some problems about my "predicate" queries.
  I have a method in my repository interface</p>
  
  <pre><code>bool IsExists(Expression&lt;Func&lt;BusinessObject,bool&gt;&gt; predicate);
  </code></pre>
  
  <p>and use it in my business layer like this; <br /></p>
  
  <pre><code>Repository r = new UserRepository(); &lt;br/&gt;
  r.IsExists(p =&gt; p.Email.Equals("email address"));
  </code></pre>
  
  <p>as you can see, its parameter is "business object", but my actual repository (that connects with database) using "dataobject" that is inside my dbml file.
  <br/></p>
  
  <pre><code>    public override bool IsExists(Expression&lt;Func&lt;DataObject, bool&gt;&gt; predicate){
  return _table.Where(predicate).Any();
  }
  </code></pre>
  
  <p>I want convert this two predicate,
  for example I'll send UserBO and convert to UserDataObject</p>
  
  <p>how can i do that?</p>