1

The query is the following:

var query = from c in _db.Table<Contact>()
            where c.FirstName.Contains("Alex")
            orderby c.Priority, c.FirstName, c.LastName
            select c;

Is it a limitation of SQLite, MvvmCross plugin? Should I go with .Syntax as a result?

Error CS1936: An implementation of `ThenBy' query expression pattern for source type `Cirrious.MvvmCross.Community.Plugins.Sqlite.ITableQuery<Contact>' could not be found (CS1936)
1
  • 1
    Definitely not a limitation of SQLite itself... You can see here that MvvmCross-SQLite implements OrderBy, but not ThenBy Apr 26, 2015 at 10:10

2 Answers 2

2

I was able to handle this by specifying mutiple OrderBy methods:

var res = _db.Table<Contact>()
 .Where(c=> c.....)
 .OrderBy(c => c.Priority)
 .OrderBy(c => c.FirstName)
 .OrderBy(c => c.LastName)
 .Select(c=> c)
 .ToList();

Translated to the SQLite query:

SELECT * FROM "Contact"
WHERE ...
ORDER BY "Priority", "FirstName", "LastName"

Hope this helped

2
  • Are you sure this is the generated SQL query? That's not how OrderBy is supposed to work. In LINQ-to-objects this would only order by LastName. Apr 27, 2015 at 20:31
  • it's a specific implementation of the SQLite MvvmCross plugin. I would glad to use ThenBy by it's not implemented (see the error from the question)
    – Mando
    May 4, 2015 at 17:08
0

You should be able to work around this limitation using a custom IComparer<T> for your Contact object. Here is an MSDN article explaining how to do this. I would recommend using IComparer<T> instead of IComparer. I think IComparer<T> did not exist when the article was written.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.