title: AutoMapper Custom Mappings
body: <p>Lets assume I have the following classes</p>
  
  <pre><code>public class foo
  {
      public string Value;
  }
  
  
  public class bar
  {
      public string Value1;
      public string Value2;
  }
  </code></pre>
  
  <p>Now I want to configure Auto Map, to Map Value1 to Value if Value1 starts with "A", but otherwise I want to map Value2 to Value.</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>Mapper
      .CreateMap&lt;foo,bar&gt;()
      .ForMember(t =&gt; t.Value, 
          o =&gt; 
              {
                  o.Condition(s =&gt; 
                      s.Value1.StartsWith("A"));
                  o.MapFrom(s =&gt; s.Value1);
                    &lt;&lt;***I want to throw Exception here***&gt;&gt;
              })
  </code></pre>
  
  <p>However I know how can I give value 1 or value 2 on Conditional basis but don't know how to put some custom code , call a function or throw an Exception</p>
  
  <p>Please Guide.</p>