I'm developing an IOS app using VS for Mac.
This query for multiple data items fails internally
IEnumerable<MyData> lst = database.Table<MyData>().Where( cw => (cw.Timestamp.Date >= fromdate.Date && cw.Timestamp.Date <= todate)).Select(r => new MyData(r));
If I "break" right after this executes, attempting to examine the "IEnumerator" member
of "lst" gives the following error:
System.NotSupportedException: Member access failed to compile expression
I have already tried disabling the "use MSBuild instead of XBuild" as some posts
recommended. And I added this to my .csproj file:
mcs.exe
All I want to do is get a List out of the query, in any way possible.
Ideally, I'd write:
return lst.AsQueryable().ToList();
(the "AsQueryable()" may not be needed; tbd).
Any help is very much appreciated!
Thanks!!!
Answers
You mixed up the usage of Linq syntax.
Here it does not need
Select
While your answer seems plausible, the end result is identical; i.e.-
Not sure where to poke next.
the IEnumerator member of "lst" still exhibits the error:
System.NotSupportedException: Member access failed to compile expression.
(and of course, lst.ToList() croaks, as it relies on IEnumerable).
I can't help thinking that I've got something configured incorrectly, OR there's
an actual bug in enumerable query results (but that just seems so unlikely, for
something this basic!).
After some more digging I found that the Table I am querying has NO records

satisfying the Where constraints. I can work around this, but I'd still expect the
query result to be an empty set (i.e. Enumerable to 0 count). Now, this feels like
a bug!
UPDATE: having no matching records was a red herring. Issue persists. BTW, removing
the Where clause (getting ALL rows in table) works fine. Obviously, I don't want to do that
Yes, it's a known issue: https://github.com/praeclarum/sqlite-net/issues/535