问题标签 [sqlite-net-pcl]
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.
sqlite - UWP SQLite Concurrent Transactions
I am developing a UWP app, which can download files concurrently and write file data to SQLite database. I have used sqlite-net-pcl as SQLite wrapper. I get DB exceptions when I am running multiple database transactions. This is sample code how I am using SQLite.
AppSQLite.cs
TopicDAL.cs
Write data to database
There can be 1000 topics for each download and user can do 100 of such downloads. So this fails with different DB exceptions as followings.
TopicDAL::AddTopic::=========Start TopicDAL::AddTopic::=========Id : d94a0a04-4bea-4b68-8757-cb304e36d16b Exception thrown: 'System.NullReferenceException' in System.Private.CoreLib.dll TopicDAL::AddTopic::=========Exception : System.NullReferenceException: Object reference not set to an instance of an object. at SQLite.PreparedSqlLiteInsertCommand.ExecuteNonQuery(Object[] source) at SQLite.SQLiteConnection.Insert(Object obj, String extra, Type objType) at SQLite.SQLiteAsyncConnection.<>c_DisplayClass33_0
1.<WriteAsync>b_0() at System.Threading.Tasks.Task1.InnerInvoke() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location where exception was thrown --- at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot) --- End of stack trace from previous location where exception was thrown --- at App.Repository.DAL.TopicDAL.AddTopic(TopicModel topicModel)=========Exception : System.ArgumentNullException: SafeHandle cannot be null. Parameter name: pHandle at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success) at SQLitePCL.SQLite3Provider_e_sqlite3.NativeMethods.sqlite3_prepare_v2(sqlite3 db, Byte* pSql, Int32 nBytes, IntPtr& stmt, Byte*& ptrRemain) at SQLitePCL.SQLite3Provider_e_sqlite3.SQLitePCL.ISQLite3Provider.sqlite3_prepare_v2(sqlite3 db, utf8z sql, IntPtr& stm, utf8z& tail) at SQLitePCL.raw.sqlite3_prepare_v2(sqlite3 db, utf8z sql, sqlite3_stmt& stmt) at SQLite.SQLite3.Prepare2(sqlite3 db, String query) at SQLite.PreparedSqlLiteInsertCommand.ExecuteNonQuery(Object[] source) at SQLite.SQLiteConnection.Insert(Object obj, String extra, Type objType) at SQLite.SQLiteAsyncConnection.<>c_DisplayClass33_0
1.<WriteAsync>b_0() at System.Threading.Tasks.Task1.InnerInvoke() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location where exception was thrown at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot) --- End of stack trace from previous location where exception was thrown ---
Can you please guide me if there is any issue withthis mplementation? If it is related to SQLite wrapper what can be the best option, to use in this scenario?
c# - C# 有没有办法为通用 T SQLiteConnection 表填充变量?
我想遍历 SQLite 数据库中的不同表并执行相同的操作。Table 中的 T 需要一个与表名匹配的类名,并用作该表中数据的容器。我想做这样的事情:
这是代码外观的一个想法:
上面给出了错误“类别是一个变量,但像一个类型一样使用。” 我尝试将类别转换为通用类型,如下所示:
targetType、genericType 和 instance 都给出相同的错误“类别是一个变量,但用作类型。” 我无法以任何方式更改数据库的结构。我不确定这是否可能,或者我是否必须为每个表编写相同的代码。
xamarin - Xamarin 无法编译:参数 System.Collections.Generic.List`1[T] queryArgs
我对 SQLite Xamarin 的查询有疑问
我已经安装sqlite-net-pcl 1.7.335并SQLiteNetExtensions 2.0.0
报错过程如下:
我的模型 PointOfSaleDTODBModel:
我调用该方法并将变量 nuevoRegistro 发送给它
在这一步是我遇到问题的地方
得到的错误是下一个:
错误文本:
- “无法编译:参数”
at SQLite.TableQuery1[T].CompileExpr (System.Linq.Expressions.Expression expr, System.Collections.Generic.List1[T] queryArgs) [0x00b16] in <d1788edcec634c19b907698bb77ed371>:0 \n at SQLite.TableQuery1[T].CompileExpr (System.Linq.Expressions.Expression expr, System.Collections.Generic.List1[T] queryArgs) [0x001fb] in <d1788edcec634c19b907698bb77ed371>:0 \n at SQLite.TableQuery1[T] .CompileExpr (System.Linq.Expressions.Expression expr, System.Collections.Generic.List1[T] queryArgs) [0x0009d] in <d1788edcec634c19b907698bb77ed371>:0 \n at SQLite.TableQuery1[T].GenerateCommand (System.String selectionList) [0x0005f] in :0 \n 在 SQLite.TableQuery1[T].ToList () [0x00000] in <d1788edcec634c19b907698bb77ed371>:0 \n at SQLite.TableQuery1[T].FirstOrDefault ( ) [0x00007] in :0 \n 在 SQLite.TableQuery1[T].FirstOrDefault (System.Linq.Expressions.Expression1[TDelegate] predExpr) [0x00007] in :0 \n at IDS.Helpers.DataAccess.Find[T] (System.Int32 pk, System.Boolean WithChildren) [0x0000e] 在 /Users/ingeneo/Documents/workspace/Xamarin /dms-mobile/dms-xamarin/IDS-only-login/IDS/Helpers/DataAccess.cs:120 \n 在 /Users/ingeneo/ 中的 IDS.Services.DataService.InsertOrUpdate[T](T 模型)[0x00002] Documents/workspace/Xamarin/dms-mobile/dms-xamarin/IDS-only-login/IDS/Services/DataService.cs:54`
任何帮助,谢谢
xamarin - 外键总是返回 0
我有一个存储数据并有 2 个外键的表“约会”。一个给customerId,一个给stylistId。我使用 ExecuteScalarAsync 创建了表,因此我可以自己创建外键,因为如果我使用 createTable 外键只是一些没有约束的数字(就像我可以为客户提供 5 的 ID,即使我没有客户编号 5)。
现在我想从我的表中取出一些约会,我需要客户 ID 来使用 .Where 函数显示数据并且一切正常,但是 customerId 和 stylistId 都是 0,即使在我的数据库中它们设置得很好。我使用 android 设备监视器来检查我的数据。
这是我的约会数据库
这是我的数据库
如果我尝试在 UserId 上查询我的约会,我会得到一个空引用异常,但如果在 id 上查询我的 userId 和 stylistId 为 0
还有我的模特
ios - IOS Xamarin SQLite 的 JIT 问题
因此,我有一些类一直存储在 Xamarin Forms 应用程序的本地 SQLite DB 中。在 UWP、Android 和 iOS 上运行良好,但在物理设备上发布除外。不断收到 JIT 警告。我已经尝试删除各种链接方式以确保它被编译但没有骰子。问题的根源似乎在于 SQLite-Net-pcl nuget 库的使用。有人对如何确保代码已被 AOT 编译有建议吗?我的抽象类,也许太抽象了?没有把握。
崩溃报告:
堆栈跟踪:
更新:似乎将 Sqlite-net-pcl 更新到 v1.8.116 是我问题的主要部分,1.6.292 也有问题。1.7.335 完美运行。
c# - 如何在 sqlite-net 中提供一个列表作为我的参数
我正在构建一个 Xamarin Forms 应用程序并使用Sqlite-net。我想运行一个删除查询,删除列表中包含字段的所有记录,如下所示:
这对我不起作用。它失败并出现错误无法存储类型:System.Collections.Generic.List1[System.Int32]。这是否意味着我已经在“(?)”的代码中构建了字符串?或者有什么方法可以将其作为参数提供。
c# - SQLite-net 插入指定表
我的应用程序正在读取两个 Excel 电子表格。一个来自 TCG 交易管理系统,另一个来自 Shopify。我想为 TCG 数据创建一个表,为 shopify 输出创建一个单独的表,但我没有看到有关如何从https://github.com/praeclarum/sqlite-执行此操作的说明net,我选择开始使用的 orm。
目的是从 TTMS csv 导出(作为 excel 文件读取)到表 A 中创建卡片对象,然后 Shopify csv 导出(以相同方式读取)选择相同的数据列来创建相同的卡片对象(使用相同的 .cs 类)但放入表 B。这是因为我希望能够对两个表进行外部联接并显示两者之间的差异。
我将如何使用 sqlite-net-pcl 库来实现这一点,和/或在不使用手动 SQL 语句的情况下这是否可能?



