在Xamarin.Mac使用SQLite-Net的扩展和SQLiteConnection [英] Using SQLite-Net Extensions and SQLiteConnection in Xamarin.Mac
问题描述
我想知道,我该如何使用 SQLite的-Net的扩展的内Xamarin.Mac项目?
I'd like to know, how can I use SQLite-Net Extensions within Xamarin.Mac project?
我用 Xamarin工作室5.9.5
,我创建的项目从Mac - > APP->空项目(统一API)。安装包 SQLite的-Net的扩展
。下面是我的代码开头:
I'm using Xamarin Studio 5.9.5
, I've created project from Mac->App->Empty project (Unified API). Installed package SQLite-Net Extensions
. Here is the beginning of my code:
var db = new SQLiteConnection(???????, dbPath);
db.CreateTable<Stock>();
db.CreateTable<Valuation>();
我怎么能叫 SQLiteConnection
构造?我需要sqlite的平台作为第一个参数,但没有 SQLite.Net.Platform。
添加引用的DLL。
How can I call SQLiteConnection
constructor? I need sqlite platform as first parameter, but there are no SQLite.Net.Platform.
dlls added to references.
这答案是没有帮助的,因为没有这样的DLL /命名空间( SQLite.Net.Platform
)。我也无法找到这个包 - SQLite.Net.Platform.XamarinIOS
。
This answer is not helpful, because there are no such dlls/namespaces (SQLite.Net.Platform
). Also I can't find this package - SQLite.Net.Platform.XamarinIOS
.
我想用 SQLite的-Net的扩展
因为它一到一,一到多..关系。我的问题是的我如何创建的SQLiteConnection?
I want to use SQLite-Net Extensions
because of its one-to-one, one-to-many.. relationships. My question is How can I create instance of SQLiteConnection?
例如为什么没有 SQLite.Net。 Platform.Generic
或 SQLite.Net.Platform.Win32
在从包中引用的DLL?
Why there is no SQLite.Net.Platform.Generic
or SQLite.Net.Platform.Win32
dlls in references from that package?
推荐答案
这个问题在项目类型,我选择。我选择空项目
为目标的新的统一的API
。对于项目 SQLiteNetExtensions
包不具有所需的库,例如 SQLite.Net.Platform.Generic
。
The problem was in project type I choose. I choose Empty project
that targets the new Unified API
. For that project SQLiteNetExtensions
package doesn’t have required libraries, such as SQLite.Net.Platform.Generic
.
要解决这个问题,你既可以选择的项目,针对经典API
(该项目 SQLiteNetExtensions
包含 SQLite.Net.Platform
),或创建统一的API
项目,后加入 SQLiteNetExtensions
包,手动添加 SQLite.Net.Platform
DLL文件的引用。
To solve that problem you could either choose project that targets Classic API
(for that project SQLiteNetExtensions
contains SQLite.Net.Platform
) or create Unified API
project and after adding SQLiteNetExtensions
package, manually add SQLite.Net.Platform
dlls to references.
虽然,我不知道为什么这些 .Platform
库都包含在 SQLiteNetExtensions
包经典API
而不是统一的API
Although, I'm not sure why these .Platform
libraries are included in SQLiteNetExtensions
package for Classic API
and not for Unified API
这是它是如何工作在我的项目:
This is how it works in my project:
dbConnection = new SQLiteConnection(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric(), databasePath);
这篇关于在Xamarin.Mac使用SQLite-Net的扩展和SQLiteConnection的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!