Page 1 of 1

how can i use SqlFunctions with dotConnect

Posted: Mon 31 Jan 2011 20:25
by skoub
Hi!

i would like to convert an Int into a string and compare it to a value directly in the database. This post http://stackoverflow.com/questions/1228 ... 50#3293050 suggest to use SqlFunctions in the Where clause and it will be converted in a sql statement that the database will know.

But with dotConnect, it doesnt seems to work. Is it possible to know how i should do it?

heres my Linq query:

Code: Select all

from commande in this.ObjectSet
where commande.TypeCommande.Nom.Contains(keyword) ||
      SqlFunctions.StringConvert((double)commande.CommandeId).Contains(keyword)
select commande;

Posted: Tue 01 Feb 2011 17:50
by rick.duarte
Try this:

Code: Select all

from commande in this.ObjectSet
where commande.TypeCommande.Nom.Contains(keyword) ||
      Devart.Data.Oracle.Entity.OracleFunctions.ToChar((decimal)commande.CommandeId).Contains(keyword)
select commande;
Best regards,

Henrique

Posted: Tue 01 Feb 2011 19:17
by skoub
great! it have solved my problem. Didnt know that there was an OracleFunctions namespace!

alex

Posted: Wed 02 Feb 2011 17:29
by AndreyR
rick.duarte, thank you for sharing the solution. We appreciate your help.