I'm trying to get linq to work with sqlite on mono, in fact using
monodevelop 2.4 and mono 2.6, and Ubuntu 10.04.1 Linux. I've tried
all the suggestions in various blogs, forum, and discussions. But
nothing works. Maybe this post will get me some relief with someone
pointing out the obvious or coming about what I need to do to get it
to work. Here's what I have done so far and just can't figure what
I'm doing wrong.
In MonoDevelop, create a solution/project call sqlinqtest. I
reference most of the assemblies suggested in various sites as follows
(although I think now it is overkill):
Mono.Data
Mono.Data.Sqlite
Mono.Data.SqliteClient
System
System.Core
System.Data
System.Data.Linq
I have a sqlite 3 database call MySampleDB.sq3. I put this in my Bin/
Debug directory. I use sqlmetal to generate the MySampleDB.cs file as
follows:
$ sqlmetal /provider:Sqlite /conn "Data Source=./MySampleDB.sq3" /
code:MySampleDB.cs
Then I moved the generated cs code to the project directory and added
this file to my project in MonoDevelop.
I edited the file to rename all "Main" in the MySampleDB.cs to be
MySampleDB is avert confusion with my Main() class.
In my Main.cs on the project, which is a console type project, I
created the following code:
using System;
using System.Data;
using Mono.Data.SqliteClient;
using System.Linq;
using DBLinq;
namespace sqlinqtest
{
class MainCLass
{
public static void Main(string[] args)
{
linqtestcode();
}
private static void linqstylecode()
{
IDbConnection dbcon;
dbcon = (IDbConnection) new SqliteConnection(
"DBLinqProvider=Sqlite; DataSource=./
MySampleDB.sq3" // per other blog, does not require
//
DbLinqDataTypeProvider if pass
//
as IDbConnection.
var db = new MySampleDB(dbcon);
var users = from u in db.User select u;
foreach( var user in users )
{ Console.WriteLine(user.uid + " " + user.name); }
}
}
}
Note, I want to use the DataContext style that I am familiar with on
Linq in MS, and I want to use Linq on Mono in Linux.
So the problem I'm having is that the table column definitions in the
query is not visible and obviously I get an error at compile saying
that "Type 'User' does not contain the definition for 'uid' and no
extension method 'uid' of type 'User' could be found", suggesting that
I may have a missing "using" directive or a missing assembly
reference.
Is this a bug? If not, how do I get this to work? Thanks.
-El
--
You received this message because you are subscribed to the Google Groups
"DbLinq" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/dblinq?hl=en.