我正在开发一个 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; }
}
当我尝试为数据库生成表时,它会引发异常:
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; }
}
谁能给我一些解决这个问题的建议?谢谢。