How to query SQLite in C# using SQL (instead of LINQ)
-
Tuesday, November 27, 2012 12:18 AM
I have been unable to find out how to perform a LINQ query with an "IN" clause; I can write the "old-fashioned" SQL easily enough, though:
StringBuilder sb = new StringBuilder();
foreach (String s in PeopleIds)
{
sb.Append(string.Format("{0,", s));
}
var sql = string.Format(
"Select * from Locations Where PlatypusId in ({0}) and SentTimeLocal >= EarliestToShow and SentTimeLocal <= LatestToShow Order by SentTimeLocal", sb.ToString());...but have not found any examples of querying SQLite in C# using SQL. Does anybody have any samples on doing that? IOW, I need some sort of a reader to read the results that I can loop through.
I'm using the latest version of SQLite and the SQLite-net bits (SQLite.cs and SQLiteAsync.cs)
All Replies
-
Wednesday, November 28, 2012 2:18 AMModerator
Hi B.Clay Shannon,
Welcome to the MSDN forum.
I am not sure what your problem is. How to perform a LINQ query with an "IN" clause? If so, what is the IN clause? Is it this: Where PlatypusId in ({0})?
If you want to know how to query SQLite in C# using SQL, this problem is off topic here. You could contact SQLite support. I find some samples you could check them:
http://zetcode.com/db/sqlitecsharp/intro/
http://blog.tigrangasparian.com/2012/02/09/getting-started-with-sqlite-in-c-part-one/
Have a nice day.
Alexander Sun [MSFT]
MSDN Community Support | Feedback to us
-
Wednesday, November 28, 2012 4:17 PM
Basically SQLite Doesn't have LINQ support, but there are third party tool that can do this. Check this out:
http://code.google.com/p/dblinq2007/
Please Mark as Reply and Vote as Helpful if I helped.
Also please visit my blog http://msguy.net/- Marked As Answer by B. Clay Shannon Wednesday, November 28, 2012 6:42 PM

