I have a linq query that returns a public class. In select new I access a property Cruising through entities database and add the value but jumps except where it says:
LINQ to Entities does not recognize the 'System.String ToString ()' method of the method, and this method can not be translated into a store expression.
where is the problem? I can navigate in a Linq .Select across linq to bd navigation properties really?
I tried to make the .Sum of several ways but I failed.
I would appreciate help.
thanks
public class prueba
{
public int Id { get; set; }
public string Nombre { get; set; }
public string Email { get; set; }
public string Codigo { get; set; }
public string Total { get; set; }
}
var result = db.cliente
.Where(p => !p.Baja.Value)
.Where(OperacionPedido(operacionPedid, numPedidos))
.Where(OperacionGastado(operacionTot, totGastado))
.Select(p => new prueba
{
Id = p.Id,
Nombre = p.Nombre + " " + p.Apellidos,
Email = p.Email,
Codigo = p.territorio1.Codigo_iso3166_3.Trim(),
Total = p.pedido.Sum(oo=>oo.Total.Value).ToString()
}).OrderBy(p => p.Nombre)
.ToList();