我正在开发一个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; }
}当我试图为数据库生成表时,它会引发异常:
“System.NotSupportedException”类型的异常发生在app_name.exe中,但未在用户代码中处理。附加信息:不知道System.Collections.Generic.List`1 app_name.Model.modelName
这来自于SqlType in SQLite.cs。
但是从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; }
}有人能给我一些解决这个问题的建议吗?谢谢。
发布于 2014-08-01 16:20:07
这通常是一个安装问题,因为SQLite-Net扩展是使用SQLite-Net库编译的,但是您正在使用另一个应用程序运行。您可以尝试将PCL NuGet包添加到项目中,也可以下载the sources from Git并直接引用该项目。
发布于 2014-05-23 09:52:41
尝试给表(Step)一个主键和一个外键引用表(WorkFlow)
[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; }
}发布于 2017-07-21 10:32:00
Fix:从所有项目卸载对任何SQLite NuGet包的所有引用,在我的例子中,这是一个Xamarin.Forms解决方案。作为额外的预防措施,清理解决方案(您甚至可以检查软件包是否已从packages文件夹中卸载,以防出现文件访问问题阻止删除)。再次安装,方法是搜索SQLiteNetExtensions (不是sqlite),并检查Visual (2017年测试)中是否选择了“包含预释放”选项。这将安装sqlit-net-PCLv1.2.0作为最小的依赖项和包括单词“Raw”在内的几个文件。您可以在此时进行测试以检查“不知道有关System.Collections.Generic.List`1”的错误。对我来说这个消失了。现在应该可以安全地将更新为最新版本,在编写本报告时该版本为v1.3.3。
背景:我遇到了同样的问题与以下组合:
在我的第一次尝试中,我首先通过NuGet安装了sqlite,然后安装了SQLiteNetExtensions的最新稳定版本。在发现这些扩展与sqlite不兼容之后,我就更新为最新的预发布版本。我遇到了同样的‘不知道关于System.Collections.Generic.List`1’的错误,并发现它非常混乱,导致我尝试其他事情,首先问我是否犯了一个错误。清理项目、删除包(从文件夹中)和还原不适合我。我没有检查软件包配置,而是使用NuGet管理器,与测试项目相比,一切都是一样的。卸载修复中提到的所有内容,并让SQLiteNetExtensions为我做依赖检查,解决了问题。我认为NuGet文件中隐藏了一个问题,因为最初使用了错误的SQLiteNetExtensions版本。
P.S.当天早些时候,NuGet为一个新的Xamarin.Forms项目下载了两个包,文件大小为0KB,是以一种典型的方式安装的,我不得不从另一个项目中复制它们。我通常不了解与NuGet相关的问题。
https://stackoverflow.com/questions/23463849
复制相似问题