how can i use SqlFunctions with dotConnect

how can i use SqlFunctions with dotConnect

Postby skoub » Mon 31 Jan 2011 20:25

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/1228318/linq-int-to-string/3293050#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;
skoub
 
Posts: 32
Joined: Fri 21 May 2010 15:47

Postby rick.duarte » Tue 01 Feb 2011 17:50

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
rick.duarte
 
Posts: 35
Joined: Fri 23 Jan 2009 23:07
Location: Rio de Janeiro, Brazil

Postby skoub » Tue 01 Feb 2011 19:17

great! it have solved my problem. Didnt know that there was an OracleFunctions namespace!

alex
skoub
 
Posts: 32
Joined: Fri 21 May 2010 15:47

Postby AndreyR » Wed 02 Feb 2011 17:29

rick.duarte, thank you for sharing the solution. We appreciate your help.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16


Return to dotConnect for Oracle