Creating records with Linq for SQLite via DbLinq

I have (after some considerable effort) got DbLinq working with the latest Mono build on OS X.

Has anyone successfully created databases via DbLinq / Sqlite?

For example, I have the following table:

CREATE TABLE UserType (
    id integer primary key,
    description text )

      

I created my * .cs file and am using the following code to try and create a new UserType entry:

UserType newUserType = new UserType();
newUserType.id = null // Attempting to get SQLite to increment
newUserType.description = "Administrator";

db.UserType.InsertOnSubmit(newUserType);

db.SubmitChanges();

      

Calling SubmitChanges throws an exception due to invalid syntax specifically related to @ (I'm assuming to do an insert in a parameterized query). It looks like the generated code is SQL Server specific. Is there a fix or flag I'm missing, or is inlining records via DbLinq in SQLite not supported?

+2


source to share


1 answer


It turns out that when using DbLinq you need to change the database connection string so that Mono System.Data.Linq knows which DB provider to use when generating SQL code.

Old:

SqliteConnection("Data Source=MyDatabase.sqlite");

      



New:

SqliteConnection("DbLinqProvider=Sqlite;Data Source=MyDatabase.sqlite");

      

It is so simple.

+3


source







All Articles