gpt4 book ai didi

c# - Sqlite 扩展没有按预期工作

转载 作者:可可西里 更新时间:2023-11-01 09:06:17 26 4
gpt4 key购买 nike

我正在开发 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; }
}

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

An exception of type 'System.NotSupportedException' occurred in app_name.exe but was not handled in user code Additional information: Don't know about System.Collections.Generic.List`1 [app_name.Model.modelName]

这来自 SQLite.cs 中的 SqlType

但是从 sqlite-net-extensions 的例子来看homepage , List 属性应该可以正常工作。

这是他们示例的副本:

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

[OneToMany] // 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 decimal Price { get; set; }

[ManyToOne] // Many to one relationship with Stock
public Stock Stock { get; set; }
}

谁能给我一些解决这个问题的建议?谢谢。

最佳答案

这通常是一个安装问题,因为 SQLite-Net Extensions 是使用 SQLite-Net 库编译的,但您正在使用另一个库运行您的应用程序。您可以尝试添加 PCL NuGet打包到您的项目中,或者您可以下载 the sources from Git并直接引用项目。

关于c# - Sqlite 扩展没有按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23463849/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com