- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
"-6ren"> "-我在我的 xamarin.forms 应用程序中使用 sqlite 网络扩展库。我在 PCL 中编写数据库代码和模型。 当我调用 SQLiteConnection.CreateTable() 时,出现-6ren">
我在我的 xamarin.forms 应用程序中使用 sqlite 网络扩展库。我在 PCL 中编写数据库代码和模型。
当我调用 SQLiteConnection.CreateTable() 时,出现错误System.NotSupportedException:不了解 Cigars.Models.Cigar
Smoke 是 Cigar 的子对象,它具有 ManyToOne 关系。以下是型号:
烟雾
public class Smoke
{
[PrimaryKey]
public int SmokeId { get; set; }
[ForeignKey(typeof(Cigar))]
public int CigarId { get; set; }
public string Notes { get; set; }
public DateTime DateCreated { get; set; }
//why is this not recognized?
[ManyToOne]
public Cigar Cigar { get; set; }
}
雪茄
public class Cigar
{
[PrimaryKey]
public int CigarId { get; set; }
public string Name { get; set; }
public double Length { get; set; }
}
导致抛出异常的数据库调用:
private SQLiteConnection db;
public Database(string path)
{
db = new SQLiteConnection(path);
db.CreateTable<Cigar>();
db.CreateTable<Smoke>(); //this throws the error
}
最佳答案
问题是我为 sqlite 安装了两个不同的库,两者都包含 SQLiteConnection
。
我需要使用Sqlite.Net.SQLiteConnection
类来进行sqlite网络扩展。不是我使用的 Sqlite.SQLiteConnection
。
正如 SushiHangover 所指出的,这个 Sqlite.Net.SQLiteConnection
采用 ISQLitePlatform
类型的第一个参数。
为了获得对此的引用,我定义了一个接口(interface),该接口(interface)提供了返回 ISQLitePlatform
的方法签名:
public interface ISQLitePlatformInstance
{
ISQLitePlatform GetSQLitePlatformInstance();
}
我在我的 Droid 项目(我正在构建的平台)中实现了该界面:
public class SQLitePlatformInstance : ISQLitePlatformInstance
{
public ISQLitePlatform GetSQLitePlatformInstance()
{
return new SQLitePlatformAndroid();
}
}
关于c# - ManyToOne 关系上的 Xamarin.Forms Sqlite-net NotSupportedException "Don' 不了解 <model>",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41668282/
目前,我有一个在我的 Mac 上运行的服务,该服务是用 C# 编写的,位于 usr/local/program。该服务能够通过根据服务器版本号检查版本号来检测何时需要更新。更新方法已运行,但是当它尝试
我们有一个下游系统,一个 ERP 系统,它可以通过 SOAP 公开其表。它发布的 Web 服务通常具有 Create、Update 和 Delete 方法。然后我们使用 svcutil 生成代理,包括
我在 Windows 商店应用程序中处理 SQLite。我正在使用更新表中的值 var tagPage = db.QueryAsync("UPDATE MyModel SET Tag =2 WHERE
我一直在努力使用 Moq 作为模拟框架并复制了一些非常简单的示例代码。我一定在这里遗漏了一些非常愚蠢的东西。它在 Setup 调用上抛出 NotSupportedException,即使它指向 Ret
为什么会抛出 System.NotSupportedException? string foo(string f) { return f; } string bar = ""; var item =
我开始遇到这个非常奇怪的问题,该应用程序在 iOS 模拟器上运行良好,但是当我在设备上启动它时,它显示登录屏幕,但在登录后,它崩溃并显示“不支持操作” “异常(exception)。堆栈跟踪是完全不可
有谁知道有什么方法可以克服 NotSupportedException?我有一个针对用户的方法: public virtual bool IsAbove(User otherUser) {
我正在对使用 IMemoryCache 的 ClientService 进行单元测试界面: 客户端服务.cs: public string Foo() { //... code
因此,我尝试在 UserDatabse.cs 类中使用此方法检索特定日期的“Sugar”类的实例: public List GetSugarDate(DateTime dt) { var
我需要在忽略大小写的情况下从数据库上下文中查找项目,但无法正常工作,到目前为止我尝试过的是: var interestingItem = ctx.MyItems.FirstOrDefault(x =>
我有这条路径可以根据日期和时间保存 Excel 工作表。它正在显示System.NotSupportedException 什么是正确的格式? string strpath = Server.M
我正在尝试返回状态更新列表,该列表按插入日期降序排列。此列表显示在局部 View 中,因此我无法使用 Controller 对列表进行排序。解决方案是创建一个包含以下代码的服务类: var Statu
如果我有一个尚未实现基类提供的函数的子类,我可以覆盖该函数并让它抛出一个NotSupportedException。有没有办法为此生成编译时错误以避免仅在运行时命中它? 更新:我不能使基类抽象。 最佳
我有一个如下所示的查询: var caseList = (from x in context.Cases where allowedCaseIds.Contains(x => x.C
我正在创建客户端-服务器应用程序。 服务器代码: public sealed class SslTcpServer { static X509Certificate serverCertifi
我正在构建一个本地化目录,但遇到了设计难题。现在,目录存储一个 Dictionary存储翻译,其中 IString可以是两种类型:Singular或 Plural .这是 IString 的简化版本:
我一直在做一个需要通过 JSON 文件保存和加载数据的项目。此 JSON 文件包含其他对象的各种列表。但是,当我继续反序列化文件时,会发生这种情况: System.NotSupportedExcept
File.ReadAllText 似乎有问题,因为即使目标文件存在,它也会返回“NotSupportedException”。无论将什么放入参数中,它都会不断抛出相同的异常。 using System
您能否帮助解决此错误的问题或说明如何以不同的方式完成此操作。谢谢! 我的任务是输出结果(集合),其中包含每个实体的注释。如果用户在选中它。 protected Expression > MapToB
LINQ 到 EF: db.ReadonlyQuery() .Select(t => new ACurrentDayInfo { OrderI
我是一名优秀的程序员,十分优秀!