✅ EFCore LINQ methods
I have this function
and naturally pages and count cannot be negative so I use uint, however I must cast it as no Skip or Take method exists for uint, is this the way it should be done or should I use int as parameters?
7 Replies
Either approach works, honestly
In one project, I just use
int
s but with a Math.Max(0, page)
In another, int
s directly
Using uint
s and casting is also validI mean, bottom line is that Linq doesn't support datasets larger than
in.MaxValue
records
if you want to write your own layers to indicate support for larger datasets, you CAN
but it's fake supportThat too,
uint
can exceed int.MaxValue
in theory you COULD write your own
.Skip()
and .Take()
methods that accept uint
and write extensions for EF to translate them into SQL
if you needed that support in the future
IMO, I would not code your business layers to pretend to have support for something that the underlying data layer doesn't
other than that, Z's right, it doesn't really matter
I mean, bottom line is that Linq doesn't support datasets larger than int.MaxValue recordsfor clarity, this is because basically EVERYTHING in Linq assumes
int
for indexes and sizes
.NET in general, for that matter
Array.Length
is int
List<T>.Count
is int
Even list and array indexes are
int
, despite negative indexes not being a thingit's a compatibility decision, really
uint
is not CLS-compliant
for whatever that's worthty will just swtich to int