Did you also check the long type? According to documentation, Int64, long and SqlInt64 represent the official equivalents of bigint.
Microsoft.EntityFrameworkCore.Sqlite C# ulong (64 bit integer) could not be translated (LINQ query)
Hi!
I'm testing database code migration from .NET Framework to .NET 5.last.
I'm using .NET 5, Microsoft.EntityFrameworkCore.Sqlite & LINQ query. (all last varsions)
Following pseudo-code fails when using correspondence C#: ulong type <==> SQLite: BIGINT type ... where...
Entity table is...
public class People
{
[Key]
public ulong ID { get; set; }
public string Name { get; set; }
}
const ulong MaxIDCompactReorderLevel = ulong.MaxValue / 2;
code fails on...
var values = from e in table
where e.ID < MaxIDCompactReorderLevel
orderby e.ID
select e;
I get following error as a result:
The LINQ expression 'DbSet<People>()
.Where(p => p.ID < 9223372036854775807)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
It looks like LINQ cannot digest ulong numbers ... like number 9223372036854775807 !?
Also, I have tried small ulong number like 100000 ... it fails!
Now I have tried to compile code from Any CPU to x64 ... hm ... LINQ fails again!
LINQ is not ulong 64-bit number compatible?
Thanks in advance,
Vladimir
P.S. when I fetch using table.FromSqlRaw RAW like ...
string sqlSelectMax = "SELECT * FROM People where ID = (SELECT max(ID) FROM People)";
table.FromSqlRaw(sqlSelectMax).ToList().First<People>() as People).ID;
... this ... succeeds.
1 additional answer
Sort by: Most helpful
-
Karen Payne MVP 35,421 Reputation points
2021-01-18T17:58:12.887+00:00 Hello @vb
This is a limitation of the SqlLite data provider which does not support BigInt You could look at ValueConverter class.