我无法在我的sessionfactory中使用SQLite Driver.
我从http://sqlite.phxsoftware.com/下载了SQLite 1.0.48
我在Tests项目中添加了对System.Data.SQLite的引用.
public static IPersistenceConfigurer GetSqlLiteConfigurer()
{
try
{
return SQLiteConfiguration
.Standard
.InMemory();
}
catch (Exception ex)
{
throw ex;
}
}
Run Code Online (Sandbox Code Playgroud)
这就是我生成配置器的方法
问题是,当我构建我的sessionfactory时,我收到以下错误:
NHibernate.HibernateException: The IDbCommand and IDbConnection implementation in the assembly System.Data.SQLite could not be found. Ensure that the assembly System.Data.SQLite is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use <qualifyAssembly/> element in the application configuration file to specify the full name …Run Code Online (Sandbox Code Playgroud) sqlite nhibernate unit-testing system.data.sqlite fluent-nhibernate
我需要连接到Sqlite中的数据库,所以我下载并安装了System.Data.SQLite,并且设计师拖了我所有的表.
设计者用.创建了一个.cs文件
public class Entities : ObjectContext
Run Code Online (Sandbox Code Playgroud)
和3个构造函数:
1
public Entities() : base("name=Entities", "Entities")
Run Code Online (Sandbox Code Playgroud)
这个从App.config加载连接字符串,并正常工作.
App.config中
<connectionStrings>
<add name="Entities" connectionString="metadata=res://*/Db.TracModel.csdl|res://*/Db.TracModel.ssdl|res://*/Db.TracModel.msl;provider=System.Data.SQLite;provider connection string="data source=C:\Users\Filipe\Desktop\trac.db"" providerName="System.Data.EntityClient" />
</connectionStrings>
Run Code Online (Sandbox Code Playgroud)
第2
public Entities(string connectionString) : base(connectionString, "Entities")
Run Code Online (Sandbox Code Playgroud)
第3
public Entities(EntityConnection connection) : base(connection, "Entities")
Run Code Online (Sandbox Code Playgroud)
这是问题,我已经尝试过n配置,已经使用EntityConnectionStringBuilder来创建没有运气的连接字符串.
能指点我正确的方向!?
EDIT(1)
如果我使用de parameterless构造函数我可以做我的查询,但我需要更改连接字符串,我不能使用我的app.config中的那个.
如何构建有效的连接字符串?!
c# sqlite connection-string system.data.sqlite visual-studio-2010
我正在阅读文章使用SQLite嵌入式数据库与实体框架和Linq-to-SQL,并尝试安装SQLite提供程序,首先使用System.Data.SQLite NuGet包,然后通过32的安装程序安装提供程序位Windows(.NET/Framework 4.0)安装程序包(适用于v1.0.79).在安装和重新启动系统之后,我仍然在Server Explorer 的Add Connection对话框中看不到SQLite Database File提供程序.
我可以通过手动创建连接字符串并使用外部工具来创建我的SQLite数据库文件,但我仍然想知道为什么我没有为SQLite提供广告设计时支持,尽管安装了最新的提供程序.这可能有什么问题?
根据http://www.sqlite.org/threadsafe.html,使用sqlite时有三种不同的线程模式:单线程,多线程和序列化.当配置为序列化和多线程模式时,使用互斥锁(取决于它们使用的模式或多或少),而在单线程模式下,根本不使用互斥锁.
假设数据库仅用于查询(只读访问),是否可以使用单线程模式,同时仍然从不同的线程访问它?还是需要保护全球资源?
另外,可以以相同的方式使用默认的ADO.NET适配器System.Data.Sqlite吗?
我的应用程序是针对.NET 4.0的,因为我们计划暂时继续支持Server 2003和Windows XP.我正在使用带有Entity Framework 4.4的Visual Studio 2012(在NuGet中列为5.0)和System.Data.SQLite的ADO.Net提供者v1.0.85.0.
我在安装设计时组件时遇到了麻烦,这些组件(1)在VS2012中工作,(2)生成针对.NET 4.0的模型和代码.为VS2012安装设计时组件的System.Data.SQLite包假定为.NET 4.5,并在从现有数据库生成模型时导致实体框架错误:
"目前的.NET Framework版本目前不支持数据类型'bigint';表'main.Message'中的列'id'被排除在外."
"目标.NET Framework版本目前不支持数据类型'binary';表'main.Message'中的'Message'列被排除在外."
等等...
我目前的解决方法是使用VS2010更新实体框架模型,但这非常烦人.有什么办法可以在VS2012上安装VS2010设计时组件吗?或者,可以将VS2012设计时组件配置为以.NET 4.0为目标吗?
sqlite entity-framework system.data.sqlite visual-studio-2012
我正在使用System.Data.SQLite在UNC路径上打开一些数据库.使用的版本是1.0.82并且运行良好.当它升级到1.0.86时,我突然发现一个错误,它无法打开数据库文件.
过了一会儿,我发现在SQLiteConnection构造函数中添加了一个名为的新参数parseViaFramework.当我把它设置为true时,一切都开始了.
但是,关于此参数实际执行的内容的信息非常少.我可以发现它与解析连接字符串的方式有关,但这是我能得到的.如果我进入parseViaFramework谷歌搜索,我只得到2页的结果.
有人能告诉我这个参数究竟是做什么的吗?
System.Data.SQLite的当前分发不适用于Visual Studio 2013,除非您部署VS2012 Update3发行包(可能)或仅安装(在我测试的测试机器上)完整版本.
有谁知道System.Data.SQLite团队何时会发布Visual Studio 2013的构建版本,我将分发给客户的预编译静态库以及我将使用的完整设计器版本?
截至本文的当前版本是1.0.89.0,其中不包括VS2013的选项.
我试图使用C#在SQLite中动态获取我的一个视图的模式.我正在使用此代码:
using (var connection = new SQLiteConnection(ConnectionString))
{
connection.Open();
using (DataTable columns = connection.GetSchema("Columns"))
{
foreach (DataRow row in columns.Rows)
{
string dataType = ((string) row["DATA_TYPE"]).Trim();
// doing irrelevant other stuff here
}
}
}
Run Code Online (Sandbox Code Playgroud)
除了一个视图外,它适用于我的所有表格和视图.由于某种原因,所调用字段的数据类型将显示为SaleAmount空白.row["DATA_TYPE"]元素中没有任何内容.
这是我的观点:
SELECT [Order Subtotals].Subtotal AS SaleAmount,
Orders.OrderID,
Customers.CompanyName,
Orders.ShippedDate
FROM Customers
JOIN Orders ON Customers.CustomerID = Orders.CustomerID
JOIN [Order Subtotals] ON Orders.OrderID = [Order Subtotals].OrderID
WHERE ([Order Subtotals].Subtotal >2500)
AND (Orders.ShippedDate BETWEEN DATETIME('1997-01-01') And DATETIME('1997-12-31'))
Run Code Online (Sandbox Code Playgroud)
我使用标准的System.Data.SQLite库.任何人都知道为什么会出现空白?就像我说的那样,在这一个视图中只发生在这一个领域.
UPDATE
我想出了如何复制这个问题.显然,如果视图包含聚合函数,例如 …
我正在使用SQLite和System.Data.Linq.Mapping.id AUTOINCREMENT使用linq mapping属性时,我遇到了该字段的问题IsDbGenerated = true.
创建表的语法.我已经尝试了这个/没有AUTOINCREMENT
CREATE TABLE [TestTable] ([id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,[title] TEXT NULL)
Run Code Online (Sandbox Code Playgroud)
我的TABLE类:
[Table(Name = "TestTable")]
public class TestTable
{
[Column(IsPrimaryKey = true, IsDbGenerated =true)]
public int id { get; set; }
[Column]
public string title { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
这是我如何称呼它.当它提交我得到一个错误,我将粘贴此示例下面的错误.需要注意的一件事是,如果我拿出IsDbGenerated =true上面的内容并id手动输入它确实插入正常,但我喜欢它,AUTOINCREMENT并且由于某种原因,它IsDbGenerated=true正在杀死插入物.寻求一些指导.
static void Main(string[] args)
{
string connectionString = @"DbLinqProvider=Sqlite;Data Source = c:\pathToDB\test.s3db";
SQLiteConnection connection …Run Code Online (Sandbox Code Playgroud) 我有下面的代码运行的2个实例,它们连接到System.Data.SQLite数据库。当我使用任一实例将行插入数据库时,从其他实例读取时,自动递增的值(ID)不合适。这背后的原因是什么?
Imports System.Data.SQLite
Public Class Form1
Public cnn As SQLiteConnection
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
cnn = New SQLiteConnection("Data Source=\\abc\xx\x_backup.db;Password=password;Connect Timeout=55;FailIfMissing=True")
cnn.ParseViaFramework = True
cnn.Open()
End Sub
Public Function inserttoTable(ByVal sql As String) As DataTable
Try
sql = "SELECT max(ID) FROM joblog;"
Dim mycommand As SQLiteCommand = New SQLiteCommand(cnn)
mycommand.CommandText = sql
MsgBox(mycommand.ExecuteScalar)
sql = "INSERT INTO joblog (jobid) VALUES (123);"
mycommand = New SQLiteCommand(cnn)
mycommand.CommandText = sql
MsgBox(mycommand.ExecuteNonQuery())
Catch ex As Exception
MsgBox(ex.ToString)
End …Run Code Online (Sandbox Code Playgroud) sqlite ×10
c# ×5
.net ×1
ado.net ×1
deployment ×1
linq ×1
nhibernate ×1
sql ×1
unit-testing ×1
vb.net ×1