title: How to use automapper with convertusing and a condition?
body: <p>We are using automapper in .net core to map viewmodels to dtos. For datetime we would like to save utc to our database, but for the user we would like to display local timezone.
  This goes well with a ConvertUsing like this:</p>
  
  <pre><code>CreateMap&lt;CreateAgendaItemViewModel, AgendaItemDto&gt;()
  .ForMember(dest =&gt; dest.StartDateTime, opt =&gt; opt.ConvertUsing(new ToUtcTimeConverter()))
  .ReverseMap()
  .ForMember(dest =&gt; dest.StartDateTime, opt =&gt; opt.ConvertUsing(new ToLocalTimeConverter()))
  </code></pre>
  
  <p>So far so good if you always want to change the time. However it is possible that only a date is set and not a time (because it is an all day event) and we would like to keep the time as is like this: 2020-04-09 00:00:00.0000000. We have a boolean in the models that indicates if it is indeed an all day event or not. How can we condition the convertusing?</p>
  
  <p>We already tried MapFrom with condition, but it cannot have a convertusing. We also tried this, but it ended up not being mapped, or being mapped to utc time.</p>
  
  <pre><code>.ForMember(dest =&gt; dest.StartDateTime, opt =&gt; { opt.Condition(src =&gt; !src.AllDayEvent); opt.ConvertUsing(new ToUtcTimeConverter()); })
  </code></pre>