Closed demon04551 closed 7 years ago
This is an expression that can be used with Lambda. Something like that:
_connection.Table< Person >().OrderByDescending(x => x.Name).FirstOrDefault(); // Get only the first element
_connection.Table< Person >().OrderByDescending(x => x.Name); // Get all elements
thank you,How do you know the sorted I want elements in what place
You can store the result in a List or Array, like that: List< Person > personList = _connection.Table< Person >().OrderByDescending(x => x.Name);
Later you can get the index of a specific element, like that: Person person = personList.Where(x => x.Name = "Name").FirstOrDefault(); // you need to import the using System.Linq to use the Where clause. int index = personList.IndexOf(person );
How to update existing data,
You need to select the data you want, change the properties and later apply the Update: List< Person > personList = _connection.Table< Person >().OrderByDescending(x => x.Name); Person person = personList.Where(x => x.Name = "Name").FirstOrDefault(); person.Name = "NewName"; _connection.Update(person);
Expression<Func<T, U>>,What is the meaning of this, how to use it