2
I have the following consultation:
var produto = (from a in context.ItensReceita
join b in context.Receita on a.t0080_id_receita equals b.t0080_id_receita
join c in context.Medicamento on a.t0080_id_receita equals c.t0051_id_medicamento
join d in context.Pessoa on b.t0031_id_paciente equals d.t0031_id_pesso
where b.t0020_id_empresa == idEmpresa
&& Convert.ToDateTime(b.t0080_dt_venda) >= Convert.ToDateTime("2017/01/01")
&& Convert.ToDateTime(b.t0080_dt_venda) <= Convert.ToDateTime("2017/01/31")
select new { b.t0080_dt_venda, d.t0031_nome, c.t0051_nome, a.t0081_lote, a.t0081_qtde, b.t0080_status });
but make that mistake:
LINQ to Entities does not recognize the method 'System.DateTime ToDateTime(System.String)' method, and this method cannot be translated into a store expression.
is not accepting conversation of dates, how can I solve it ?
Pablo, I tried the way q vc suggested and gave the same error, I believe q is by trying to talk about the property && Convert.Todatetime(b.t0080_dt_venda)
– alessandre martins
Yes, I just edited the answer, I had not seen this detail of your dt_venda field
– Pablo Tondolo de Vargas
One thing, your sale is a Datetime?
– Pablo Tondolo de Vargas
no, it’s a string, I’ll have to change right...
– alessandre martins
It would be nice, @alessandremartins. If you’re saving a date, it’s good to be a camp
DateTime
, not astring
.– Jéf Bueno
I think it would be more convenient to change.
– Pablo Tondolo de Vargas
when trying to use Dbfunctions.Truncatetime, do so in innerException: FUNCTION zulex01.Truncatetime does not exist, I edited the post, see the Debug image
– alessandre martins
Which database you are using?
– Pablo Tondolo de Vargas
mysql database
– alessandre martins
see if Function of this answer helps you http://stackoverflow.com/a/19731414/2221388 create it in your database
– Pablo Tondolo de Vargas
well, now did not give the error more than FUNCTION zulex01.Truncatetime does not exist, however Mysql expects the date in format yyyy/MM/dd, Dbfunctions.Truncatetime() asks for a parameter of type datetime, datetime needs to be formatted for yyyyyy/MM/dd, all formatting q axei, the output is a string.
– alessandre martins
Alessandre, I think figuring out how to use Dbfunctions.Truncatetime would fit another question.
– Pablo Tondolo de Vargas