Method SQLite.Net.SQLiteConnection.Table: type argument 'T' violates the constraint of type parameter 'T'.
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)
-
-
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.
-
As @deet mentioned you can downgrade to SQLite.Net v2.x until a fix is applied. This commit changes the type checking to
class
fromnew()
and it's causing the issue. -
Thanks, I did downgrade and it worked.
-
- changed status to resolved
Fixed in 1.3.0
-
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.
-
@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 .
-
@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!
-
@LukeG47 I feel your pain. I even have a script for deleting all
bin
andobj
folders of projects in workspace :D - Log in to comment
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