title: Automapper System.Exception "Can't resolve this to Queryable Expression"
body: <p>I'm trying to use a custom value resolver in automapper to get the difference between 2 dates at run time. </p>
  
  <p><strong>The Resolver</strong></p>
  
  <pre><code>public class TotalDaysResolver : ValueResolver&lt;JobPersonnel, double&gt;
  {
      protected override double ResolveCore(JobPersonnel source)
      {
          var totalDays = CalculateDaysBetween(source.LeaveOffice.GetValueOrDefault(), source.ReturnOffice.GetValueOrDefault());
  
          return totalDays;
      }
  
      private double CalculateDaysBetween(DateTime d1, DateTime d2)
      {
          if (d1 &gt;= DateTime.Now || d1 == DateTime.MinValue) return 0;
          d2 = SetTimeNowIfDateOutIsMinValue(d2);
  
          var span = d2.Subtract(d1);
          var totalDays = span.TotalDays.ToString("F2");
  
          return Double.Parse(totalDays);
      }
  
      private DateTime SetTimeNowIfDateOutIsMinValue(DateTime d2)
      {
          if (d2 == DateTime.MinValue)
              d2 = DateTime.Now;
          return d2;
      }
  }
  </code></pre>
  
  <p><strong>ViewModel</strong></p>
  
  <pre><code>public class PersonnelVM
  {
      public int Refno { get; set; }
      public int JobID { get; set; }}
      [UIHint("StartDate")]
      public DateTime? LeaveOffice { get; set; }
      [UIHint("EndDate")]
      public DateTime? ReturnOffice { get; set; }
      public double TotalDays { get; set; }
  }
  </code></pre>
  
  <p><strong>Mapping</strong></p>
  
  <pre><code>CreateMap&lt;PersonnelVM, JobPersonnel&gt;()
              .ReverseMap()
              .ForMember(dst =&gt; dst.TotalDays, opt =&gt; opt.ResolveUsing&lt;TotalDaysResolver&gt;()));
  </code></pre>
  
  <p><strong>Query</strong></p>
  
  <pre><code>public IEnumerable&lt;PersonnelVM&gt; GetAllPersonnelByJobId(int jobid)
  {
      return _dbRepository.GetWhere&lt;PersonnelVM, JobPersonnel&gt;(w =&gt; w.JobID == jobid); //This is where I get the error
  }
  </code></pre>
  
  <p>The mapping doesn't throw any errors if I comment out the map for TotalDays. Unfortunately I can't find any information online to point me in any direction of solving this issue. I'm new to programming and newer to automapper.</p>
  
  <p>Does anyone have insight into this error and/or how I can go about debugging this issue myself?</p>