找不到方法'SQLiteConnection.InsertAll' [英] Method 'SQLiteConnection.InsertAll' not found

查看:138
本文介绍了找不到方法'SQLiteConnection.InsertAll'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在(当前)Android Samsung S6手机上的数据库中使用多对多数据库关系.为此,我正在使用SQLite.Net-PCL 3.0.5和SQLiteNetExtensions 1.3.0. 我曾经有过简单的SQlite访问功能,但是现在我尝试建立多对多关系(通过链接表),当我打电话时,sqlite-net-extensions抛出了 m_DatabaseConnection.UpdateWithChildren(article);

I'm trying to get many-to-many database relationships working in my database on (currently) an Android Samsung S6 mobile. To this end I am using SQLite.Net-PCL 3.0.5 and SQLiteNetExtensions 1.3.0. I have had simple SQlite access working fine, but now I have attempted to setup a many to many relationship (via a linking table), the sqlite-net-extensions are throwing when I call m_DatabaseConnection.UpdateWithChildren(article);

例外是:

System.MissingMethodException: Method 'SQLiteConnection.InsertAll' not found.

这很奇怪,因为我反汇编了dll并确定它确实存在.我的数据类的结构是:

Which is weird, as I disassembled the dll and established that it definitely does exist. The structure of my data classes are:

public class Article : BaseModel
{
    public Article()
    {
        Audience = new List<Tag>();
        Content = new List<Tag>();
        Weather = new List<Tag>();
    }

    ...   

    [ManyToMany(typeof(ArticleTag))]
    public List<Tag> Audience { get; set; }
    [ManyToMany(typeof(ArticleTag))]
    public List<Tag> Content { get; set; }
    [ManyToMany(typeof(ArticleTag))]
    public List<Tag> Weather { get; set; }

   ....
}

    public class ArticleTag
{
    [ForeignKey(typeof(Article))]
    public int ArticleID { get; set; }
    [ForeignKey(typeof(Tag))]
    public int TagID { get; set; }
}

public class Tag : BaseModel
{
    ...
}

public class BaseModel
{
    public BaseModel()
    {

    }

    [PrimaryKey, AutoIncrement]
    public int ID { get; set; }

    public bool Dirty { get; set; }
}

那么我在做什么错了?我是否需要包含其他版本的SQLite.Net-PCL?我尝试下载并编译扩展项目,但是似乎出现了错误(由于我没有iOS许可证,所以我不得不卸载iOS项目,但其余的应该已经编译了.)

So what am I doing wrong? Do I need to include a different version of SQLite.Net-PCL? I tried downloading and compiling the extension project, but there seemed to be errors (I had to unload the iOS projects, as I don't have a licence for iOS, but the rest should have compiled).

有什么想法吗?

-更新---

似乎该行必须在"WriteOperations.cs"中:

It seems that the line in question must be within "WriteOperations.cs":

private static void UpdateManyToManyForeignKeys(this SQLiteConnection conn, object element, PropertyInfo relationshipProperty)
    {
...

    conn.InsertAll(missingIntermediateObjects);

    ..
    }

然后转到SQLiteExtensions-MvvmCross,并且必须找不到接口的实现.所以,问题是,我是否需要其他NuGet软件包?

This then goes off to SQLiteExtensions-MvvmCross and must fail to find the implementation of the interface. So, question is, do I need other NuGet packages?

推荐答案

所以,这似乎是误解了它是如何工作的,以及1.3被破坏了.

So, it looks like it's a combination of misunderstanding how this is intended to work, and 1.3 being broken.

我回滚到1.2.5,它停止引发异常.但实际上并没有保存.然后,我查看了项目源代码中包含的测试用例(在此处提供: https://bitbucket.org/twincoders/sqlite-net-extensions ),发现他并没有直接挽救多对多关系.相反,他插入了初始实体,然后在相同实体上调用UpdateWithChildren来填写链接表.这似乎有效.我尚不清楚为什么不将其合并为一个呼叫,但是它允许我继续前进.

I rolled back to 1.2.5 and it stopped throwing exceptions. But didn't actually save. I then looked at the test cases included within the project source (available here: https://bitbucket.org/twincoders/sqlite-net-extensions) , and saw that he didn't do a straight save on a many-to-many relationship. Instead he inserted the initial entities, then call UpdateWithChildren on the same entities to fill out the linking tables. This seems to work. I'm unclear why this isn't rolled into one call, however it allows me to move on.

这篇关于找不到方法'SQLiteConnection.InsertAll'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆