title: EF Core using Let in query throw "Argument types do not match" exception
body: <p>I'm using EF Core 2.0.1. I'm trying to get the last order data along with a user info to populate UserDto as follows,</p>
  
  <pre><code>(from u in DbContext.User.Where(u =&gt; u.UserId == userId)
  let last = u.Orders.LastOrDefault()
  select new UserDto
  {
      Id = u.Id,
      Name = u.Name,
      LastOrderId = (last == null ? null : last.Id),
      LastOrderDate = (last == null ? null : last.Date)
  }
  </code></pre>
  
  <p>This throws following exception. How can I fix this?</p>
  
  <pre><code>at System.Linq.Expressions.Expression.Condition(Expression test, Expression ifTrue, Expression ifFalse, Type type)
  at System.Linq.Expressions.ConditionalExpression.Update(Expression test, Expression ifTrue, Expression ifFalse)
  at System.Linq.Expressions.ExpressionVisitor.VisitConditional(ConditionalExpression node)
  at System.Linq.Expressions.ConditionalExpression.Accept(ExpressionVisitor visitor)
  at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
  at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.RelationalProjectionExpressionVisitor.Visit(Expression expression)
  at System.Linq.Expressions.ExpressionVisitor.VisitMemberAssignment(MemberAssignment node)
  at System.Linq.Expressions.ExpressionVisitor.VisitMemberBinding(MemberBinding node)
  at System.Linq.Expressions.ExpressionVisitor.Visit[T](ReadOnlyCollection`1 nodes, Func`2 elementVisitor)
  at System.Linq.Expressions.ExpressionVisitor.VisitMemberInit(MemberInitExpression node)
  at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.RelationalProjectionExpressionVisitor.VisitMemberInit(MemberInitExpression memberInitExpression)
  at System.Linq.Expressions.MemberInitExpression.Accept(ExpressionVisitor visitor)
  at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
  at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.RelationalProjectionExpressionVisitor.Visit(Expression expression)
  at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.VisitSelectClause(SelectClause selectClause, QueryModel queryModel)
  at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.VisitSelectClause(SelectClause selectClause, QueryModel queryModel)
  at Remotion.Linq.Clauses.SelectClause.Accept(IQueryModelVisitor visitor, QueryModel queryModel)
  at Remotion.Linq.QueryModelVisitorBase.VisitQueryModel(QueryModel queryModel)
  at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.VisitQueryModel(QueryModel queryModel)
  at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.VisitQueryModel(QueryModel queryModel)
  at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateAsyncQueryExecutor[TResult](QueryModel queryModel)
  at Microsoft.EntityFrameworkCore.Storage.Database.CompileAsyncQuery[TResult](QueryModel queryModel)
  at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileAsyncQueryCore[TResult](Expression query, INodeTypeProvider nodeTypeProvider, IDatabase database)
  at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.&lt;&gt;c__DisplayClass24_0`1.&lt;CompileAsyncQuery&gt;b__0()
  at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
  at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddAsyncQuery[TResult](Object cacheKey, Func`1 compiler)
  at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileAsyncQuery[TResult](Expression query)
  at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query)
  at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.ExecuteAsync[TResult](Expression expression)
  at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1.System.Collections.Generic.IAsyncEnumerable&lt;TResult&gt;.GetEnumerator()
  at System.Linq.AsyncEnumerable.&lt;Aggregate_&gt;d__6`3.MoveNext()
  </code></pre>