I just upgrade to EF 3 and one of my queries that used to work, gives an exception now
ProductionRecords = _context.ProductionRecords
.Where(r => r.DataCriacao.Date == DateTime.Now.Date)
.Select(pr => new ProductionRecordViewModel
{
Id = pr.Id,
Operador = pr.Operador,
DataCriacao = pr.DataCriacao,
Celula = pr.Celula.Name,
Turno = pr.Turno.Name,
TotalPecasSemDefeito = pr.ReferenceRecords.Sum(c => c.Quantity),
TotalPecasComDefeito = pr.DefectRecords.Sum(c => c.Quantidade),
TotalTempoParado = pr.StopRecords.Sum(c => Convert.ToInt32(c.Duration.TotalMinutes)),
})
.AsNoTracking()
.ToList();
The exception happens when i'm trying to sum the collection with the timespan with the duration....
How am i supposed to handle this now?
here is the exception
InvalidOperationException: The LINQ expression '(EntityShaperExpression: EntityType: StopRecord ValueBufferExpression: (ProjectionBindingExpression: EmptyProjectionMember) IsNullable: False ).Duration.TotalMinutes' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.