I tried to find what causes the issue
LINQ to Entities does not recognize the method 'Int16 Parse(System.String)' method, and this method cannot be translated into a store expression
The error happens when the execution hits the if
condition. The line if (query.Any())
throws the exception and I couldn't figure why. Can you spot the problem?
My query:
var query = from clt in vclt.cltpar
join p in vclt.profession //left join
on clt.no_prof equals p.no_prof
into temp
from prof in temp.DefaultIfEmpty()
where
clt.no_pays == short.Parse(no_pays) &&
clt.tp_pid == tp_pid &&
clt.no_pid == no_pid &&
clt.no_seq == short.Parse(no_seq)
select new
{
clt.no_pays,
clt.tp_pid,
clt.no_pid,
clt.no_seq,
dt_cre = clt.dat_nais,
DesigClt = vclt.get_nompren(clt.no_pays, clt.tp_pid, clt.no_pid, clt.no_seq).ToString(),
AdrClt = prtf.adresseclt(clt.no_pays, clt.tp_pid, clt.no_pid, clt.no_seq).ToString(),
CodRisque = vclt.get_coderisque(clt.no_pays, clt.tp_pid, clt.no_pid, clt.no_seq).ToString(),
FormeJur = "",
Secteur = prof.lib_prof,
Registre = "",
MatFisc = "",
NumTeleph = prtf.get_numtel(clt.no_pays, clt.tp_pid, clt.no_pid, clt.no_seq).ToString(),
DateDebRel = ogcc.get_datdebrel(clt.no_pays, clt.tp_pid, clt.no_pid, clt.no_seq).ToString(),
RNE = "",
cd_dou = "0"
};
if (query.Any())
{
stuff here
}
Update I did as told i converted outside the query as follow
short n_pays = short.Parse(no_pays.ToString());
short n_seq = short.Parse(no_seq.ToString());
BUT this throws an exception that couldn't be resolved even when i used ToString()