I have the following data
ItemId | ItemName | ItemBy | ItemCreatedOn
1 | A100 | User1 | 2016-10-04
2 | A200 | User1 | 2016-10-04
3 | A300 | User1 | 2016-10-04
4 | A400 | User1 | 2016-10-04
5 | A600 | User1 | 2016-10-04
6 | D100 | User1 | 2016-10-04
7 | D900 | User1 | 2016-10-04
8 | D200 | User1 | 2016-10-04
9 | D300 | User1 | 2016-10-04
This is what I want to return:
ItemId | ItemName | ItemBy | ItemCreatedOn
5 | A600 | User1 | 2016-10-04
My approach
Get all the list of items starting with A
var allItems = db.Items.Where(x.ItemName[0] == itemName[0]).ToList();
use substring
var items = allItems.Select(x => x.Substring(1));
The above returns a list of string, but I want to return a list of all the items without A so that I can use Max() on ItemName to get the record I need
How can I return the list of objects and then use Max correctly?
BCinABC600come from? There are no such characters in your example.