XamarinのSQLiteについていくつかのスレッドを読んだが、まだセットアップできない。SQLiteNetExtensionsが適切な方法で設定されている。私は現在、ターゲットフレームワークAndroid 7.1(APIレベル25 - ヌガット)でアンドロイドアプリを開発しています。Android-App用XamarinでSQLiteNetextensionsを使用
誰でも私が間違っていることを教えてもらえますか?
私はnugetパッケージインストール:その後、私は私のコードを設定https://bitbucket.org/twincoders/sqlite-net-extensions
:によると
Install-Package SQLiteNetExtensions -Version 2.0.0-alpha2 -Pre
Install-Package SQLite.Net-PCL -Version 3.1.1
を。
using SQLite.Net.Attributes; using SQLiteNetExtensions.Attributes; using System; namespace AppName.Resources.Model { public class Entry { [PrimaryKey, AutoIncrement] public int Id { get; set; } [ForeignKey(typeof(Stock))] public int StockId { get; set; } public DateTime Date { get; set; } public double Amount { get; set; } } }
using SQLite.Net.Attributes; using SQLiteNetExtensions.Attributes; using System; using System.Collections.Generic; namespace AppName.Resources.Model { public class Stock { [PrimaryKey, AutoIncrement] public int Id { get; set; } public string Name { get; set; } public DateTime LastUpdated { get; set; } [OneToMany(CascadeOperations = CascadeOperation.All)] public List<Entry> Entrys { get; set; } } }
using Android.Util; using AppName.Resources.Model; using SQLite.Net; using SQLite.Net.Platform.XamarinAndroid; using SQLiteNetExtensions.Extensions; using System.Collections.Generic; using System.IO; namespace AppName.Resources.DataHelper { public class DataBase { string folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); public bool CreateDataBase() { try { using (var stocksDBConnection = new SQLiteConnection(new SQLitePlatformAndroid(), Path.Combine(folder, "Stock.db"))) { stocksDBConnection.CreateTable<Entry>(); stocksDBConnection.CreateTable<Stock>(); return true; } } catch (SQLiteException ex) { Log.Info("SQLiteEx", ex.Message); return false; } } public bool InsertIntoTableStock(object stock) { try { using (var stocksDBConnection = new SQLiteConnection(new SQLitePlatformAndroid(), Path.Combine(folder, "Stock.db"))) { stocksDBConnection.InsertWithChildren(stock); return true; } } catch (SQLiteException ex) { Log.Info("SQLiteEx", ex.Message); return false; } } ...
これらの参考文献はnugetにより添加した:
SQLite-net
SQLite.Net
SQLite.Net.Platform.XamarinAndroid
SQLiteNetExtensions
SQLitePCLRaw.Batteries_green
SQLitePCLRaw.Core
SQLitePCLRaw.lib.e_sqlite3
SQLitePCLRaw.provider.e_sqlite3
Occuringエラー:
'SQLiteConnection' does not contain a definition for 'InsertWithChildren' and the best extension method overload 'WriteOperations.InsertWithChildren(SQLiteConnection, object, bool)' requires a receiver of type 'SQLiteConnection'
'SQLiteConnection' does not contain a definition for 'GetAllWithChildren' and the best extension method overload 'ReadOperations.GetAllWithChildren(SQLiteConnection, Expression>, bool)' requires a receiver of type 'SQLiteConnection'
はまあそれは私が得るどのくらいです。何をすべきかを知っている人はいませんか?おそらく競合する参照を削除しますか?
これに関するニュースはありますか?私はまだ更新されたsqlitenetextensionsが働くことができません... –
私の "編集"私のためのトリックでした。それが役に立てば幸い。 – Muffex