sqlite.net

Xamarin.Forms using SQLite.Net.Async

自古美人都是妖i 提交于 2020-03-22 08:42:25
问题 I have followed the instructions here http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/databases/ - to connect to the SQLite database synchronously. public SQLiteConnection GetConnection() { var dbFilname = "localDB.db3"; string docsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); var path = Path.Combine(docsPath, dbFilname); var plat = new SQLitePlatformAndroid(); var conn = new SQLiteConnection(plat, path); return conn; } I

SQLite .NET, ExecuteScalarAsync<int>, how to know when there was no result?

不羁岁月 提交于 2019-12-23 21:36:26
问题 The SQL statement is retrieving the ID of a row. But there may be no such row. When I executed a particular SQL statement in a GUI tool, it returned "0 rows returned in 0ms from:...". However, when I executed the same SQL statement with ExecuteScalarAsync<int> , it returned 0, and no exception or null occurred. How do I know if there was no such row? Theoretically, there can be a row whose ID is 0. PS: It is SQLite-net which I added using Nuget (https://github.com/praeclarum/sqlite-net). Its

SQLite.Net, C# equivalent for SQLite bit datatype

时间秒杀一切 提交于 2019-12-11 13:08:43
问题 I declare following class in c# [Table("Employee")] public class Employee { [PrimaryKey,AutoIncrement] public int EmployeeId { get; set; } public DateTime DateOfJoining { get; set; } public string Address{ get; set; } } and i invoke this method to create equivalent table in my SQLite database public async Task CreateTable() { SQLiteAsyncConnection conn = new SQLiteAsyncConnection(path); await conn.CreateTableAsync<Employee>(); } So it creates a table in SQLite as follows [EmployeeId] int,

How can you store lists of objects in SQLite.net?

你说的曾经没有我的故事 提交于 2019-12-10 04:01:49
问题 Let us assume I have these two objects class Customer { [PrimaryKey] public string id; [??????] public List<int> addresses; } and class Address { [PrimaryKey, AutoIncrement] public int id; public string street; public int number; } Is there a way to use the SQLite.NET ORM to save the Customers object? cause I'm having a really hard time saving lists. If there is no such way, is there some sort of event I can implement or method I can override so that when an object gets loaded code will

SQLite.NET - System.NotSupportedException: Cannot compile: Parameter

青春壹個敷衍的年華 提交于 2019-12-08 18:06:43
问题 I am using SQLite.NET Async (http://www.nuget.org/packages/SQLite.Net.Async-PCL/) in a Xamarin iOS project, but I am having a problem using the table predicate queries. Anytime I use the Get method below, which is very simple, I receive an exception that the expression could not be compiled, System.NotSupportedException: Cannot compile: Parameter. However, if I use a low level query, as with the GetQuery method, it works fine. Is there something I am doing wrong in the definition of my table

How to return Wrapper obj of TableOjb1 and TableObj2 using linq

只谈情不闲聊 提交于 2019-12-08 17:28:17
问题 class TableObj1 { public string Id {get; set;} public string Name {get; set;} } class TableObj2 { public string Id {get; set;} public string Email {get; set;} } class MergeObj { public TableObj1 Obj1 {get; set;} public TableObj2 Obj2 {get; set;} } My question is how to return a list of MergeObj when joining the two tables. I tried: public IEnumerable<MergeObj> QueryJoin() { return ( from obj1 in conn.Table<TableObj1>() join obj2 in conn.Table<TableObj2>() on obj1.Id equals obj2.Id select new

sqlite.net + monotouch = SIGSEGV crashes

主宰稳场 提交于 2019-12-07 09:18:04
问题 We're using the following: Xamarin 3 (Xamarin Forms) MonoTouch sqlite.net iOS simulator/hardware The app synchronizes data with a server on a background thread. There is only one SQLite connection object shared by the entire app. Foreground queries are executed at the same time the background sync is running. All of this has worked fine on a Windows 8.1 version of the app (i.e., on MSFT Surface and similar). However once we switched to Xamarin/mono we started getting constant crashes as shown

How to use InsertOrReplace in sqlite.net PCL?

橙三吉。 提交于 2019-12-01 03:31:19
I am using the PCL version of sqlite.net from here ( https://github.com/oysteinkrog/SQLite.Net-PCL ). Here is my simple class. public class LogEntry { [PrimaryKey, AutoIncrement] public int Key { get; set;} public DateTime Date { get; set; } } When a new instance of LogEntry is created, the Key is automatically set to 0. I set the Date to something and then call InsertOrReplace. The record does get saved in my database. The Key field gets the autoincrement value which happens to be 0 since it is the first record. I then create a new instance of LogEntry (Key is automatically initialized to 0)