System.NotSupportedException: Order By does not support in sqlite

Hi Guys,

I want to try condition in orderby SQLite but it's supported have you any solution?

    contactRespDetail.contact = _connection.Table<Contact>()
      .OrderBy(s => s.Fullname)   // supported
      .OrderByDescending(x => x.Companyname.Contains("Temporary Contact")) // do's not supported.
      .Where(x => x.StateCode == 0)
      .Skip(skip)
      .Take(take)
      .ToList();

Thanks.

Tagged:

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai

    @Sheemu

    .OrderByDescending(x => x.Companyname.Contains("Temporary Contact")) // do's not supported.
    

    OrderBy and OrderByDesending is used to sort the fetched data according to one or more columns. But 'x.Companyname.Contains("Temporary Contact")' is not a column which has been added in database.

    Add the 'x.Companyname.Contains' condition in Where sentence.

  • SheemuSheemu USMember ✭✭

    Thank you @yelinzh,

    actually, I have need add where condition within orderbydescending clause as I have mentioned on this line: OrderByDescending(x => x.Companyname.Contains("Temporary Contact")).

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited July 23

    How about the sql sentence?

  • SheemuSheemu USMember ✭✭

    like this: contactRespDetail.contact = _connection.Table()
    .OrderByDescending(x => x.Companyname.Contains("Temporary Contact")) // do's not supported.
    .Where(x => x.StateCode == 0)
    .Skip(skip)
    .Take(take)
    .ToList();

  • JarvanJarvan Member, Xamarin Team Xamurai

    Use query syntax like:

    List<Mountain> list = (from xxx in table_name orderby xx where xx == xx)).ToList();
    
Sign In or Register to comment.