Sqlite扩展无法按预期工作

Bri*_*ang 10 c# windows-runtime windows-store-apps sqlite-net sqlite-net-extensions

我正在开发一个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]

这来自SqlTypeSQLite.cs.

但从sqlite-net-extensions 主页上的例子来看,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; }
}
Run Code Online (Sandbox Code Playgroud)

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

red*_*t84 9

这通常是一个安装问题,因为SQLite-Net Extensions是使用SQLite-Net库编译的,但是您使用另一个运行App.您可以尝试将PCL NuGet包添加到项目中,也可以从Git下载源代码并直接引用该项目.


MJ3*_*J33 3

尝试给步骤)一个主键和一个外键引用工作流程

[Table("Step")]
public class Step
{
    [PrimaryKey, AutoIncrement]
    public int StepId { get; set; }
    [ForeignKey(typeof(WorkFlow))]
    public int WorkFlowId { get; set; }
    public string Type { get; set; }
    public string Description { get; set; }
    [ManyToOne]
    public Workflow Workflow { get; set; }
}
Run Code Online (Sandbox Code Playgroud)