codeice / linqtoexcel

Automatically exported from code.google.com/p/linqtoexcel
0 stars 0 forks source link

doesn't work with System.String functions? #61

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

Something like this works:

(assuming one of the values of "code" is "hello")

my_string="hello";

 var dr = (from r in excel.Worksheet()
                         where my_string ==(r["code"])
                         select r).FirstOrDefault();

but THIS, does not:

 var dr = (from r in excel.Worksheet()
                         where my_string.Contains(r["code"])
                         select r).FirstOrDefault();

this does not find a match. :-(

Using this on Windows 2008 R2, 64-bit.

Man, this is so cool.  close, but no cigar for my application.

Original issue reported on code.google.com by dalega...@gmail.com on 10 Feb 2012 at 9:30

GoogleCodeExporter commented 8 years ago
where my_string.Contains(r["code"]) creates an invalid SQL statement. (SELECT * 
FROM Worksheet WHERE "hello" LIKE code)

You can swap the statement though. 

where r["code"].Contains(my_string) 

which creates this valid SQL statement: SELECT * FROM Worksheet WHERE code LIKE 
'%hello%'

Original comment by paulyo...@gmail.com on 10 Feb 2012 at 10:26