简体   繁体   English

在Xamarin.Mac中使用SQLite-Net Extensions和SQLiteConnection

[英]Using SQLite-Net Extensions and SQLiteConnection in Xamarin.Mac

I'd like to know, how can I use SQLite-Net Extensions within Xamarin.Mac project? 我想知道,如何在Xamarin.Mac项目中使用SQLite-Net Extensions

I'm using Xamarin Studio 5.9.5 , I've created project from Mac->App->Empty project (Unified API). 我正在使用Xamarin Studio 5.9.5 ,我已经从Mac-> App-> Empty project(Unified API)创建了项目。 Installed package SQLite-Net Extensions . 安装包SQLite-Net Extensions Here is the beginning of my code: 这是我的代码的开头:

        var db = new SQLiteConnection(???????, dbPath);
        db.CreateTable<Stock>();
        db.CreateTable<Valuation>();

How can I call SQLiteConnection constructor? 如何调用SQLiteConnection构造函数? I need sqlite platform as first parameter, but there are no SQLite.Net.Platform. 我需要sqlite平台作为第一个参数,但没有SQLite.Net.Platform. dlls added to references. dlls添加到引用。

This answer is not helpful, because there are no such dlls/namespaces ( SQLite.Net.Platform ). 这个答案没有帮助,因为没有这样的dll /名称空间( SQLite.Net.Platform )。 Also I can't find this package - SQLite.Net.Platform.XamarinIOS . 另外我找不到这个包 - SQLite.Net.Platform.XamarinIOS

I want to use SQLite-Net Extensions because of its one-to-one, one-to-many.. relationships. 我想使用SQLite-Net Extensions因为它具有一对一,一对多的关系。 My question is How can I create instance of SQLiteConnection? 我的问题是如何创建SQLiteConnection实例?

Why there is no SQLite.Net.Platform.Generic or SQLite.Net.Platform.Win32 dlls in references from that package? 为什么在该包的引用中没有SQLite.Net.Platform.GenericSQLite.Net.Platform.Win32 dll?

The problem was in project type I choose. 问题出在我选择的项目类型中。 I choose Empty project that targets the new Unified API . 我选择针对新Unified API Empty project For that project SQLiteNetExtensions package doesn't have required libraries, such as SQLite.Net.Platform.Generic . 对于该项目, SQLiteNetExtensions包没有必需的库,例如SQLite.Net.Platform.Generic

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. 要解决该问题,您可以选择针对Classic API项目(针对该项目的SQLiteNetExtensions包含SQLite.Net.Platform )或创建Unified API项目,并在添加SQLiteNetExtensions包之后,手动将SQLite.Net.Platform dll添加到引用。

Although, I'm not sure why these .Platform libraries are included in SQLiteNetExtensions package for Classic API and not for Unified API 虽然,我不确定为什么这些。 .Platform库包含在Classic API SQLiteNetExtensions包中,而不包含在Unified API

This is how it works in my project: 这是它在我的项目中的工作方式:

dbConnection = new SQLiteConnection(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric(), databasePath);

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

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