简体   繁体   English

Xamarin SQLite PCL实现

[英]Xamarin SQLite PCL implementation

I'm creating a Xamarin application with a PCL and I would like to use SQLite in the PCL to share the database code within the platform specific projects. 我正在用PCL创建一个Xamarin应用程序,我想在PCL中使用SQLite在平台特定项目中共享数据库代码。

I've already looked into the Tasky Portable project, where they are using an abstract class to reach this goal. 我已经研究过Tasky Portable项目,他们使用抽象类来实现这个目标。 I've had some trouble implementing this method, which is why I was looking for another solution to use SQLite within a PCL. 我在实现这个方法时遇到了一些麻烦,这就是为什么我在寻找另一种在PCL中使用SQLite的解决方案。 I stumbled upon an Xamarin Forms article where they are using the SQLite PCL NuGet package to implement it in a PCL. 我偶然发现了一篇Xamarin Forms文章 ,他们使用SQLite PCL NuGet包在PCL中实现它。

Since I'm not using Xamarin Forms, what is the difference between these two methods? 由于我没有使用Xamarin Forms,这两种方法有什么区别? Can the NuGet package solution also be used to implement SQLite within the PCL without using Xamarin Forms? NuGet包解决方案是否也可用于在PCL中实现SQLite而无需使用Xamarin Forms? This method seems a lot simpler than the abstract class. 这个方法似乎比抽象类简单得多。

The SQLite PCL package that is used by the Xamarin Forms example uses SQLite.Net. Xamarin Forms示例使用的SQLite PCL包使用SQLite.Net。 The Tasky Portable project is using SQLite. Tasky Portable项目正在使用SQLite。 The difference is the SQLite.Net is a wrapper over SQLite. 区别在于SQLite.Net是SQLite的包装器。 You use SQLite.Net as an ORM and not not worry about the implementation details. 您使用SQLite.Net作为ORM,而不是担心实现细节。 Instead you can create your POCOs in your PCL and decorate them with the appropriate attributes. 相反,您可以在PCL中创建POCO并使用适当的属性进行装饰。 The Tasky Portable project is just an older way of doing things in a PCL. Tasky Portable项目只是PCL中较旧的一种做事方式。 Now you have the newer way of doing things with SQLite.Net. 现在,您可以使用SQLite.Net进行更新的方式。

Xamarin Forms is not a prerequisite or co-requisite for using SQLite.Net. Xamarin Forms不是使用SQLite.Net的先决条件或必备条件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM