Method SQLite.Net.SQLiteConnection.Table: type argument 'T' violates the constraint of type parameter 'T'.

Issue #63 resolved
Adrien Pellegrini created an issue

Hello,

In a WinRT Universal App project I got this following error : "Method SQLite.Net.SQLiteConnection.Table: type argument 'T' violates the constraint of type parameter 'T'." when I call the method GetAllWithChildrenAsync with a simple class.

I replaced in ReadOperations.cs (both project)

where T : new()

by

 where T : class, new()

That solved the problem.

Hope it helps.

Regards, Adrien.

Comments (9)

  1. Michael Marsh

    I'm getting the same error in my WPF project when calling GetAllWithChildren inside a PCL. Any idea how to fix this without creating a custom build?

    Thanks

  2. deet

    For those looking, I believe this is related to upgrading SQLite.Net-PCL to version 3.0.x, which seems to have added stricter checking on the type of T as the OP stated.

    Michael, if you can you could consider reverting to an older version of SQLite.Net-PCL.

  3. Guillermo Gutiérrez

    As @deet mentioned you can downgrade to SQLite.Net v2.x until a fix is applied. This commit changes the type checking to class from new() and it's causing the issue.

  4. Lukas G

    Hm, unfortunately I got the same error, when I call dbSyncConn.GetAllWithChildren<SessionObject>()

    I'm using

    SQLiteNetExtensions.Async v1.3.0

    SQLiteNetExtensions v1.3.0

    SQLite.Net-PCL v3.0.5

    SQLite.Net.Core-PCL v3.1.1

    SQLIte.Net.Async-PCL v3.1.1

    Any idea how to solve this? I've tried so much already.

  5. Guillermo Gutiérrez

    @LukeG47 You have two different SQLite.Net versions (3.0.5 and 3.1.1). Try switching SQLIte.Net.Async-PCL to v3.0.5 and removing SQLite.Net.Core-PCL v3.1.1 .

  6. Lukas G

    @redent Thank you so much, you pushed me in the right direction. I tried different versions, installed, un-installed, deleted the "bin" folder, cleaned project etc.

    BUT: There is also a "obj" folder which contained some old .dll -> Almost went crazy but now it's working. Thank you for your time!

  7. Guillermo Gutiérrez

    @LukeG47 I feel your pain. I even have a script for deleting all bin and obj folders of projects in workspace :D

  8. Log in to comment