问题标签 [sqlite-net]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
610 浏览

c# - sqlite-net 中 FirstOrDefault() 和 Where() 之间的语义差异

因为我找到了解决方案,所以比实际问题更清晰。我只是不明白其中的道理...

使用 SQLite 3.8.3.1 使用 SQLite-net 2.1

.Where(lambda).FirstOrDefault()我看到运行 a和运行 a之间的明显区别.FirstOrDefault(lambda)

就我在 Linq 方面的经验而言,数据库 LINQ 提供程序对这两者的处理基本相同(.FirstOrDefault(lambda)如果优化得当,可能会快一点,但总的来说,这两个调用的运行时间大致相同)。

但是,在 SQLite-net 中,我在一个包含约 40,000 条记录的表上看到以下结果:

运行时.FirstOrDefault(x => x.Id == id),我看到 Core-i7 的时间在2200 毫秒到 3700 毫秒之间。在 Surface RT(第一代)上,这实际上需要大约 20,000 毫秒到 30,000 毫秒。

运行时.Where(x => x.Id == id).FirstOrDefault(),我看到相同 Core-i7 的时间在16ms-20ms之间。在 Surface RT 上,这大约需要 30 毫秒。

我的问题是这是否只是一个错误,或者这是否是一个有意识的设计决定。如果这是一个设计决定——我很想了解它背后的原因。

0 投票
3 回答
4974 浏览

c# - Sqlite 扩展未按预期工作

我正在开发一个 WinRT 应用程序。我想用来sqlite-net-extensions支持OneToManyManyToMany

当我尝试为数据库生成表时,它会引发异常:

app_name.exe 中出现“System.NotSupportedException”类型的异常,但未在用户代码中处理其他信息:不了解 System.Collections.Generic.List`1 [app_name.Model.modelName]

这是从里面传来SqlTypeSQLite.cs

但是从sqlite-net-extensions 主页上的示例来看,List属性应该可以正常工作。

这是他们示例的副本:

谁能给我一些解决这个问题的建议?谢谢。

0 投票
1 回答
519 浏览

xamarin - SQLite-NET 安装指南

我是 Xamarin、MonoTouch 和 C# 的新手,但我已经掌握了窍门。我SQLite-NET在这里找到https://github.com/praeclarum/sqlite-net但我不确定如何“安装”它,我的意思是,我应该只使用该SQLite.cs文件,还是引用整个项目等。 .

在 Xamarin 项目中使用 SQLite-NET 的步骤是什么?

0 投票
1 回答
333 浏览

sqlite - 安装后如何检查应用程序是否第一次运行?

在他们的设备上下载并安装应用程序后,如何检查 widnows phone 8.1 应用程序是否首次运行?

我的场景是,我想在应用程序下载并首次运行后使用 sqlite-net 创建一些表。以及在应用程序中使用 sqlit-net 创建数据库/数据表的最佳实践是什么?

我正在使用 windows phone 8.1 通用应用程序。

谢谢

0 投票
2 回答
1778 浏览

c# - 如何使用 SQLite-Net 扩展实现递归关系

我有一个必须具有递归关系的表Employee ,例如。

第 1 行: EmployeeId = 1EmployeeName = AlbertSupervisorId = NULL

第 2 行EmployeeId = 2EmployeeName = LeonardoSupervisorId = 1

即 EmployeeId( 2 ) 是 EmployeeId( 1 )的子代

我在 C# 中有以下代码,其中我使用SQLite-Net 扩展来实现递归关系:

接下来我测试代码——我创建了两个员工并将它们添加到表Employee中:

第一名员工

第二名员工

但是当我打电话时

guid是第一个员工,我收到以下错误:

附加信息:“Project.Models.Employee”类型的对象无法转换为“System.Collections.Generic.List`1”类型

SQLite-Net 是否支持递归关系?请问有什么建议吗?

更新

GetByGuid() 的代码:

此外,当我添加第二名员工而不指定外键并进行调用时,它可以工作......

0 投票
2 回答
625 浏览

c# - What's the default file path in WinRT/WP 8.1?

Hello fellow programmers.

I recently made a mistake while using the SQLite-NET package for Windows Phone 8.1. When opening a new SQLiteConnection, I would give as parameter to its constructor the string "data.db", without being actually aware of what was going on under the hood. Later on, I noticed that the file wouldn't be deleted, even if I uninstalled the application (since I would have in my app the same entries that I had before uninstalling it); I assume that I should be using the local folder for application data instead. However, here is the real question: what the hell is the folder where the data.db file was created? I tried to figure it out with the following piece of code:

and what I got as output of the WriteLine method was the path

C:\Data\SharedData\PhoneTools\AppxLayouts\f7529f24-ba24-4fdb-8353-cff9214180a0VS.Debug_ARM.Valbrand\data.db,

which only got me even more confused. I couldn't find any satisfactory info on this, and I would REALLY like to further my understanding of what happened here.

Thanks in advance!

0 投票
1 回答
1706 浏览

c# - 使用 SqliteNet 时出现异常

尝试使用 sqliteNET 执行任何操作时,我不断收到错误消息。我得到例外:

我的代码如下所示:

它在 create table 语句处失败。

这是 URMMobileAccount 类:

我一直在广泛研究这一点,似乎无论出于何种原因,当它尝试创建表映射时,它通过反射获取所有属性,然后执行:

props是属性列表,cols是一个 List<Column>. 忽略ignore变量 p.CanWrite 为该类中的所有属性返回 false?不能这样写,因为 CanWrite 是由具有 setter 方法的属性确定的,对吧?

0 投票
1 回答
783 浏览

c# - 通用应用程序中的 Sqlite-net - 我的数据库在哪里?

以前我曾在 Windows Phone 8 的 Silverlight 应用程序中使用 LocalDb,它在 8.1 上也很有效。

如果我想检查我的数据库,我使用 ISETOOL 下载文件并将其附加到 vs.

管理层让我为 RT 构建一个“通用”应用程序。我正在采用 SQLite-net。

在我的应用程序中,我调用:

我可以看到数据被保留了,因为如果我执行插入然后提交然后在另一种方法中检索它一切正常。

但是,当我使用 ISETOOL 时,没有任何东西从模拟器复制到我的本地文件夹。

我的 SQLite 数据库在哪里?

0 投票
2 回答
11257 浏览

c# - SQLite database query with multiple WHERE conditions

Trying to develop a Windows 8.1 Store App. Amongst other difficulties, I need to retrieve records from a sqlite database with two parameters on the where clause. I can successfully query with one parameter in the where clause but it crashes everything when I try to use two parameters. Here is my code for this:

Please refer to the line in which existingmaintenance variable is defined. The commented out version of this line works fine. When I substitute the variable definition with the two parameter query (obtained using a different method because I couldn't figure out how to add a second parameter to the Table query approach), it crashes.

Thanks for any help you can give. Sorry that I only half understand what I'm doing.

0 投票
3 回答
7765 浏览

primary-key - 创建 SQLite 数据库的 AutoIncrement 附近的语法错误

又是我,那个使用 SQLite-net 的人。当我的表的主键上没有 AutoIncrement 时,我的代码可以正常工作。我想自动增加键,所以我重建了这样的表:

现在,当尝试创建表时,我得到“AutoIncrement 附近的语法错误”。我尝试不使用 AutoIncrement,但没有它似乎不会增加 ID。

我可能错过了一些愚蠢的东西。