Switched from Sqlite.net-pcl to sqlite-net-pcl. Now child objects null on GetAllWithChildrenAsync

Issue #120 new
Weston Eighmy created an issue

Hello

we had been using SQLite.net-pcl previously but had to make an abrupt switch because of encoding issues we uncovered which were echoed elsewhere by other teams.

When swapping to sqlite-net-pcl I was relieved to see this project had migrated its dependencies as well. We use it a lot :) The version we upgraded to is SQLiteNetExtensions.Async.2.0.0-alpha2

However, I am noticing the following no longer works for us.

We had classes declared that enforced generic inheritance like so:

public abstract class AbstractViewModel<T> : where T : AConcreteClass
{
public async Task Example()
{
     var con = db.AsyncConnection;

      var masterList = await con.GetAllWithChildrenAsync<T>(null, true);
}
}

When swapping base sqlite library to sqlite-net-pcl I notice the Generic arguments for db table queries, etc require inheriting from new(), where as before you could use class.

So I updated my class like so:

public abstract class AbstractViewModel<T> : where T : AConcreteClass, new()
{
public async Task Example()
{
     var con = db.AsyncConnection;

      var masterList = await con.GetAllWithChildrenAsync<T>(null, true);
}
}

And thankfully it compiles!

However now in the returned results all children are null. The only change to the models themselves were to swap out the namespace so our meta tags would compile (Table, Column, etc). The first code sample above was working before having to migrate the libraries.

Is our approach still viable with the new dependencies or is this just a bug? I would be happy to provide any additional info as this will force a major refactor if unable to get it working.

****UPDATE I tested this in a plain class and referenced the table directly, ie:

var masterList = await con.GetAllWithChildrenAsync<MyMasterClass>(null, true);

It still returns null unfortunately.

Thanks!

Comments (7)

  1. Weston Eighmy reporter
    • edited description

    updated with test using model class directly instead of via Generic

  2. Weston Eighmy reporter

    I have pulled the source code and tracked down the issue.

    Our models are OneToOne relational (If I change the relationships to OneToMany the children are loaded as expected)

    Previously we had used SQLiteNetExtensions 1.3, but now are on the pre release packages. In July (2015) there was an update that is in the pre release packages which are required for sqlite-net-pcl plugin (unless you use NetStandard).

    I fixed it with two lines of code but have only verified it works for our scenario.

    I had to update our Mac to get the Tests to compile so I will try them out with our new code.

  3. Weston Eighmy reporter

    I found the source of issue and made a change that seemed to fix it however I was unable to run tests. You can see an example of what had to change here

    Ultimately another user has forked the repo to change the same method and I ended up using their version which works fine (We have compiled this version and use it as an external dll dependency). Sorry I cannot remember what fork I ultimately used...

    Also, it's been a while so I am not sure if original source has been updated to remedy this issue.

  4. Log in to comment