标签: sqlite-net-extensions

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<Step> Steps { get; set; }
}

[Table("Step")]
public class Step
{
    public string Type { get; set; }
    public string Description { get; set; }
    [ManyToOne]
    public Workflow Workflow { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

当我尝试为数据库生成表时,它会引发异常:

app_name.exe中出现"System.NotSupportedException"类型的异常但未在用户代码中处理其他信息:不了解System.Collections.Generic.List`1 [app_name.Model.modelName]

这来自 …

c# windows-runtime windows-store-apps sqlite-net sqlite-net-extensions

10
推荐指数
2
解决办法
4630
查看次数

如何使用 SQLite.Net-PCL 制作 SQLite 外键

在 UWP 中,我享受使用 SQLite.Net-PCL 的好处,创建要在应用程序中使用的类作为 ObservableCollections 以绑定到 GridView。在包含 SQLiteNetExtensions 以构建带有外键的数据库后,我注意到在 SQLite Maestro 中查看数据库时并未真正创建外键。而是创建索引。 如果 SQLiteNetExtensions 并没有真正创建外键,那么使用它有什么好处?

使用 LAMDA 表达式或 LINQ 进行查询时,可能不需要外键(稍后在创建数据库后的应用程序中)。 如果我在不使用 SQLite.Net-PCL 的情况下执行查询以创建带有外键的表,我是否仍然可以使用 SQLite.Net-PCL 继续将 ObservableCollections 绑定到 GridViews?

示例数据库:

[Table("Book")]
public class Book
{
    [PrimaryKey, AutoIncrement, Column("ID")]
    public int ID { get; set; }
    [Column("Name")]
    public string Name { get; set; }

    [ManyToMany]
    public List<Checkout> Checkout { get; set; }
}

[Table("School")]
public class School
{
    [PrimaryKey, AutoIncrement, Column("ID")]
    public int ID { get; set; }
    [Column("Name")]
    public string …
Run Code Online (Sandbox Code Playgroud)

c# sqlite-net sqlite-net-extensions uwp

9
推荐指数
1
解决办法
8299
查看次数

SQLite-Net扩展两个实体之间的一对一和一对多关系

我正在使用SQLite-Net PCL和SQLite-Net扩展来开发使用Xamarin的应用程序.

在我的模型中,我有两个实体,让我们称它们为A和B,它们通过一对一和一对多的关系连接起来.例如,A与B具有一对一的关系,A与B具有一对多的关系.

是否可以用SQLite-Net扩展表达这种行为?

sqlite xamarin sqlite-net sqlite-net-extensions

7
推荐指数
1
解决办法
7155
查看次数

使用SQLite-Net Extensions和OneToMany关系

我在尝试为Windows Phone 8.1实现具有OneToMany关系的SQLite-Extensions示例时遇到了困难.我真的很想使用这个功能,但是我正在试着让它发挥作用.就像在这个问题中一样,当我尝试将提供的示例用于具有Valuations列表的Stocks表时:

public class Stock
{
    [PrimaryKey, AutoIncrement]
    public int Id { get; set; }
    [MaxLength(8)]
    public string Symbol { get; set; }

    [OneToMany(CascadeOperations = CascadeOperation.All)]      // One to many relationship with Valuation
    public List<Valuation> Valuations { get; set; }
}

public class Valuation
{
    [PrimaryKey, AutoIncrement]
    public int Id { get; set; }

    [ForeignKey(typeof(Stock))]     // Specify the foreign key
    public int StockId { get; set; }
    public DateTime Time { get; set; }
    public …
Run Code Online (Sandbox Code Playgroud)

c# sqlite sqlite-net windows-phone-8.1 sqlite-net-extensions

6
推荐指数
1
解决办法
3862
查看次数

SQLite-net-pcl - Always returning ID as 0 (Xamarin)

I recently moved across from SQLite.NET to SQLite-net-pcl due to the Android 7.0 SQlite issue.

In the process I have updated all my libraries and all is working well with regards to insert/drop etc.

我唯一的问题是,每次从数据库中检索项目时,它的ID始终为0。这会导致更新项目的问题。有人遇到过这个问题吗?

 [SQLite.PrimaryKey, SQLite.AutoIncrement]
    public int ID { get; set; }
    public string objectId { get; set; }
    public DateTime createdAt { get; set; }
    public DateTime updatedAt { get; set; }
    public string Title { get; set; }
Run Code Online (Sandbox Code Playgroud)

提前致谢。

xamarin sqlite-net sqlite-net-extensions

6
推荐指数
2
解决办法
2228
查看次数

SQLite-Net扩展与SQLite-Net PCL的兼容性(请注意,没有句号)

基本上,我的问题归结为SQLite-Net扩展NuGet链接)是否与Frank A. Krueger的SQLite-net PCL兼容。据我了解,在某个时候,Oystein Krog创建了一个分叉来改进过去的功能(可能在Frank更新之前?),因此SQLite.Net PCL诞生了。

既然有PCLFrank 的“官方” 版本,我想坚持使用它而不是fork。但是,目前尚不清楚是否SQLite-Net Extensions仅支持fork。该网站表示支持,SQLite-net但相关性却说SQLite.net。为我(和将来的人们)的缘故所做的任何澄清将不胜感激!!!

编辑:我知道“ SQLite-Net PCL”只是NuGet包的名称,实际上不是独立的PCL。我有这个(没有SQLite-Net扩展),可以在我实际的PCL中的代码中完全工作。

portable-class-library xamarin sqlite-net-extensions

5
推荐指数
1
解决办法
981
查看次数

sqlite.net表子表上的条件

我正在使用Xamarin表单,SQLite.net和SQLitenet扩展,我无法弄清楚为什么我希望简单的东西不起作用.

我有两节课

public class MeasurementInstanceModel
{
    public MeasurementInstanceModel ()
    {
    }

    [PrimaryKey]
    [AutoIncrement]
    public int Id {
        get;
        set;
    }

    [ForeignKey(typeof(MeasurementDefinitionModel))]
    public int MeasurementDefinitionId {
        get;
        set;
    }

    [ManyToOne(CascadeOperations = CascadeOperation.CascadeRead)]
    public MeasurementDefinitionModel Definition {
        get;
        set;
    }

    [ForeignKey(typeof(MeasurementSubjectModel))]
    public int MeasurementSubjectId {
        get;
        set;
    }

    [ManyToOne(CascadeOperations = CascadeOperation.CascadeRead)]
    public MeasurementSubjectModel Subject {
        get;
        set;
    }

    public DateTime DateRecorded {
        get;
        set;
    }

    [OneToMany(CascadeOperations = CascadeOperation.All)]
    public List<MeasurementGroupInstanceModel> MeasurementGroups {
        get;
        set;
    }
}
Run Code Online (Sandbox Code Playgroud)

public class MeasurementSubjectModel
{


    [PrimaryKey] …
Run Code Online (Sandbox Code Playgroud)

c# sqlite.net xamarin.forms sqlite-net-extensions

4
推荐指数
1
解决办法
4646
查看次数

使用 SQLite.Net.Async 扩展 PCL 1.3.0 在同一对象上使用多个 @OneToOne?

是否可以使用 SQLite.Net.Async Extensions PCL 1.3.0 在一个实体中拥有多个 OneToOne 关系?

例子:

[Table("body")]
public class Body
{
    [OneToOne(CascadeOperations = CascadeOperation.All)]
    [Column ("left")]
    public Hand Left { get; set; }

    [OneToOne(CascadeOperations = CascadeOperation.All)]
    [Column ("right")]
    public Hand Right { get; set; }
}

[Table("hand")]
public class Hand
{
    // In this I do not need a reference back to Body.
}
Run Code Online (Sandbox Code Playgroud)

我一直在尝试使用以下答案:

SQLite-Net 扩展两个实体之间的一对一和一对多关系

并以这些网站为灵感:

https://bitbucket.org/twincoders/sqlite-net-extensions/overview

https://bitbucket.org/twincoders/sqlite-net-extensions/src/65a1f8519347c40c948855cfc1a1d4d8bbcc8748/Tests/ReflectionExtensionsTests.cs?at=master&fileviewer=file-view-default

不幸的是,到目前为止还没有运气。甚至有可能吗?

sqlite xamarin sqlite-net sqlite-net-extensions

4
推荐指数
1
解决办法
941
查看次数

SQLite Net Extensions OneToMany 关系不插入/保存/更新子级

我正在尝试使用 SQLite Net Extensions 为游戏做一个笔记应用程序,它使用 3 层模型, Game [1 has many *] Character [1 has many *] Note [1 applies to *] Character

我在 Visual Studio Community 2015 中使用 Xamarin,并使用 NuGet 包管理器安装了 SQLiteNetExtensions。

我还没有通过游戏和角色之间的第一级关系,插入数据库(无论是通过初始插入然后更新,还是递归使用 InsertWithChildren)都不会更新游戏对象中的角色。它只会为List<CharacterModel>内部 GameModel 生成一个空对象。然而,游戏和角色都在数据库中。

抽象基础模型

public abstract class IdentifiableModel
{
    [PrimaryKey, AutoIncrement]
    public int Id { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

游戏模型

[Table("Game")]
public class GameModel : IdentifiableModel
{
    [MaxLength(64)]
    public string Name { get; set; }

    [OneToMany]
    public List<CharacterModel> Characters { get; set; }
} …
Run Code Online (Sandbox Code Playgroud)

c# xamarin sqlite-net sqlite-net-extensions

4
推荐指数
2
解决办法
4530
查看次数

SQLiteAsyncConnection UpdateWithChildren 不可用

我正在尝试使用 SQLite.net 在我的 PCL 内实现 OneToMany 关系。我有异步扩展包(SQLiteNetExtensions.Async),并且我的代码基于https://bitbucket.org/twincoders/sqlite-net-extensions中找到的示例 。我正在使用 SQLiteAsyncConnection,但 UpdateWithChildren 方法似乎不可用,只能使用 SQLiteConnection。

using SQLite.Net;
using SQLite.Net.Async;
using SQLite.Net.Interop;
using SQLiteNetExtensions.Extensions;

private readonly SQLiteAsyncConnection conn;
public ActivityRepository(ISQLitePlatform platform, string dbPath)
{
    var connectionFactory = new Func<SQLiteConnectionWithLock>(() => new SQLiteConnectionWithLock(platform, new SQLiteConnectionString(dbPath, storeDateTimeAsTicks: true)));
    conn = new SQLiteAsyncConnection(connectionFactory);
}
public void method(object object) {
    conn.UpdateWithChildren(object); --function not available
}
Run Code Online (Sandbox Code Playgroud)

xamarin sqlite-net-extensions

4
推荐指数
1
解决办法
2161
查看次数