问题描述
我已经(在一些显著努力)得到的DBLinq使用Mono对OS X的最新版本的工作。
I have (after some significant effort) gotten DbLinq working with the latest build of Mono on OS X.
有没有人successfulyl通过的DBLinq / SQLite的创建数据库实体?
Has anybody successfulyl created database entities via DbLinq/Sqlite?
例如,我有如下表:
CREATE TABLE UserType (
id integer primary key,
description text )
我已生成我* .cs文件和我使用下面的代码试图创建一个新的用户类型条目:
I have generated my *.cs file and am using the following code to attempt to 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();
要的SubmitChanges的调用乱扔无效语法的例外具体涉及到@ (我猜在一个参数化查询做插入)。它看起来像正在生成的代码是SQL Server的具体。是否有修补程序或标志我失踪,或通过插入的DBLinq记录的SQLite不支持?
The call to SubmitChanges is throwing an exception about invalid syntax specifically related to @ (I'm guessing in a parameterized query to do the insert). It looks like the code being generated is SQL Server specific. Is there a fix or flag I'm missing, or is inserting records through DbLinq to SQLite not supported?
推荐答案
原来, 。使用时的DBLinq,你需要修改数据库连接字符串,Mono的将System.Data.Linq知道它的生成SQL代码时使用的DB提供程序
Turns out that when using DbLinq, you need to modify the DB Connection string so Mono's System.Data.Linq knows which DB provider to use when generating its SQL code.
老:
SqliteConnection("Data Source=MyDatabase.sqlite");
新:
SqliteConnection("DbLinqProvider=Sqlite;Data Source=MyDatabase.sqlite");
这是这么简单。
It's as simple as that.
这篇关于使用LINQ创建通过记录到的DBLinq SQLite的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!