Tag: sqlite net

SQLite.NET – System.NotSupportedException:无法编译:参数

我在Xamarin iOS项目中使用SQLite.NET Async( http://www.nuget.org/packages/SQLite.Net.Async-PCL/ ),但我在使用表谓词查询时遇到问题。 无论何时我使用下面的Get方法,这很简单,我收到一个exception,表达式无法编译,System.NotSupportedException:无法编译:参数。 但是,如果我使用低级查询,就像使用GetQuery方法一样,它可以正常工作。 在我的表的定义或阻止sqlite.net编译表达式的方法中,我做错了吗? public interface IDataModel { [PrimaryKey, AutoIncrement] int Id { get; set; } } public class BaseDataModel : IDataModel { [PrimaryKey] public virtual int Id { get; set; } } [Table(“Event”)] public class EventDataModel : BaseDataModel { public string Name { get; set; } public int OrganizationId { […]

ManyToOne约束不起作用

我的关系非常简单,我的模型看起来像这样: public class Project { [PrimaryKey, AutoIncrement] public int ID { get; set; } public string Name { get; set; } [ForeignKey(typeof(User))] public int ProjectManagerID { get; set; } [ManyToOne] public User ProjectManager { get; set; } } public class User { public string Login { get; set; } [OneToMany] public List Projects { get; […]

sqlite.net + monotouch = SIGSEGV崩溃

我们使用以下内容: Xamarin 3(Xamarin表格) MonoTouch的 sqlite.net iOS模拟器/硬件 该应用程序与后台线程上的服务器同步数据。 整个应用程序只共享一个SQLite连接对象。 前台查询在后台同步运行的同时执行。 所有这些都适用于Windows 8.1版本的应用程序(即在MSFT Surface和类似版本)。 然而,一旦我们切换到Xamarin / mono,我们开始不断崩溃,如下所示。 研究导致了这篇文章: http : //www.aaronheise.com/2012/12/monotouch-sqlite-sigsegv/ 他正在使用Mono.Data.SqliteClient,而不是像我们一样使用sqlite.net。 他的解决方案涉及显式处理Command对象以确保GC可以保持等等。当我尝试将我的Command对象(来自sqlite.net)包装在using(){}子句中时,我发现它们不是一次性的。 我尝试插入100毫秒延迟并停止崩溃,但对我们来说这不是一个可行的解决方案。 这里对sqlite.net有什么希望,或者我应该寻找一种不同的方式来使用sqlite? mono-rt: Stacktrace: mono-rt: at mono-rt: at (wrapper managed-to-native) SQLite.SQLite3.Prepare2 (intptr,string,int,intptr&,intptr) … mono-rt: Native stacktrace: mono-rt: Got a SIGSEGV while executing native code. This usually indicates a fatal error in the mono runtime […]

如何在SQLite.net中存储对象列表?

我们假设我有这两个对象 class Customer { [PrimaryKey] public string id; [??????] public List addresses; } 和 class Address { [PrimaryKey, AutoIncrement] public int id; public string street; public int number; } 有没有办法使用SQLite.NET ORM来保存Customers对象? 因为我很难保存列表。 如果没有这种方式,是否有某种我可以实现的事件或我可以覆盖的方法,以便当一个对象被加载时代码会触发? 我正在考虑在地址列表上方添加[忽略]的方法,当事件触发时我可以使用SQLite.net从另一个表加载地址的ID 提前感谢您提供的任何帮助

Sqlite一对多关系

我正在制作一个需要存储和从sqlite数据库获取数据的应用程序。 我目前使用的两个Nuget包是Sqlite PCL和SQLite-Net Extensions 。 [Table(“patient”)] public class Patient { [PrimaryKey] public string ID { get; set;} public string FirstName { get; set; } public string LastName { get; set; } [OneToMany] public List PatientVitals { get; set; } } [Table(“patientVitals”)] public class PatientVitals { [PrimaryKey] public string VitalID {get;set;} public string Weight { get; […]

在应用更新上升级数据库

我正在开发一个Windowsapp store应用程序,它使用SQLite for Windows Runtime Extension和sqlite-net库将数据存储在本地SQLite数据库中。 此数据库是在Windows.Storage.ApplicationData.Current.LocalFolder.Path路径中创建的。 一切都像它应该的那样,我想我提交时不会有问题。 问题1 但是当我更改应用程序,再次提交并且用户更新它时会发生什么? 数据库文件会被删除吗? 用户会丢失他的数据吗? 问题2 我是否可以使用旧数据库并在应用程序版本之间升级? 我知道在开发Android应用程序时该怎么做但是这个Windows Store Update过程对我来说是新的,我害怕做一些让我无法恢复用户数据的错误。 如果有人已经通过它,请告诉我它是如何工作的。 提前致谢

我可以在用于SQLite的类中使用String列表吗?

SQLite-net将用于表示表的类中使用的数据类型有哪些限制? 具体来说,我可以使用这个: public List CoconutWaterBrands { get; set; } ……或者我需要这个: public string[] CoconutWaterBrands { get; set; } ……还是别的什么?

Sqlite扩展无法按预期工作

我正在开发一个WinRT应用程序。 我想使用sqlite-net-extensions来支持OneToMany , ManyToMany 。 using SQLiteNetExtensions.Attributes; using SQLite; [Table(“WorkFlow”)] public class Workflow { [PrimaryKey, AutoIncrement] public int WorkflowId { get; set; } public string Name { get; set; } public int Revision { get; set; } [OneToMany] public List Steps { get; set; } } [Table(“Step”)] public class Step { public string Type { […]

是否可以从Sqlite查询返回动态对象或数据集?

我在我的Xamarin.Forms应用程序中使用Sqlite.Net 。 到目前为止,如果我的对象是这样的类,那么返回对象列表非常棒: SqliteDatabase.Connection.Query(“Select * from Customers”); 我现在想从查询中动态返回DataSet的等价物 SqliteDatabase.Connection.Query(“Select * from Customers inner join Calls on Customers.Id=Calls.CustomerId”) 现在从第二个查询我想返回一个DataSet而不是一个对象列表。 我知道我可以创建一个新的对象,它组合了Customers和Calls的列,但我不想每次想要查询数据库时都要创建对象。 是否可以动态返回Dataset或Object ?

Xamarin项目中SQLite-Net的通用存储库

我想知道是否有办法为我的Xamarin项目编写通用存储库,而不是为我的对象中的每个实体编写不同的存储库。 Xamarin Tasky Pro示例为Task实体提供了一个Repository,因为它是它拥有的唯一实体。 在我自己的项目中,我有多个实体,所以我的问题是如何使以下客户存储库变得通用,以便ProductManager,EmployeeManager等可以使用它。 如果你知道一个例子或博客文章,请指出我正确的方向 namespace App.DataLayer { public class CustomerRepository { private ProntoDatabase _db = null; protected static string DbLocation; protected static CustomerRepository Me; static CustomerRepository() { Me = new CustomerRepository(); } protected CustomerRepository() { //set the db location; DbLocation = DatabaseFilePath; //instantiate the database _db = new ProntoDatabase(DbLocation); } public static string […]