問題タブ [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.

0 投票する
0 に答える
56 参照

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_01.<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_01.<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?

0 投票する
0 に答える
34 参照

c# - C#ジェネリック T SQLiteConnection テーブルの変数を入力する方法はありますか?

SQLite データベース内のさまざまなテーブルをループして、同じアクションを実行したいと考えています。Table の T は、テーブル名と一致するクラス名を想定し、そのテーブル内のデータのコンテナーとして機能します。私はこのようなことをしたい:

コードがどのように見えるかのアイデアは次のとおりです。

上記は、「カテゴリは変数ですが、タイプのように使用されています」というエラーを出します。次のように、カテゴリをジェネリック型に変換しようとしました。

targetType、genericType、および instance はすべて、「カテゴリは変数ですが、型のように使用されます」という同じエラーを返します。データベースの構造を変更することはできません。これが可能かどうか、または各テーブルに同じコードを記述する必要があるかどうかはわかりません。