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]
这来自SqlType于SQLite.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)
谁能给我一些解决这个问题的建议?谢谢.
尝试给表(步骤)一个主键和一个外键引用表(工作流程)
[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)