I have the following classes:
public class Menu
{
public int Order { get; set; }
public string Title { get; set; }
public string Status { get; set; }
public string Type { get; set; }
public bool Default { get; set; }
public string Link { get; set; }
public string Notes { get; set; }
public string Text { get; set; }
}
public class MenuItem
{
public int Order { get; set; }
public string Title { get; set; }
public string Type { get; set; }
public bool Default { get; set; }
public string Link { get; set; }
}
Also this which returns ICollection
var menu = _menuRepository.GetPk(pk);
Can someone show me how I can use LINQ to:
a) Get the data from menu
b) Select only rows where Status = "00"
c) Order by Order
d) Put the data into the MenuItem class
I heard there are maybe two ways of coding this. Can anyone explain these and advise which would be better.
Try this:
You can throw
.ToList()at the end to materialize collection immediately.