What I have is a binding list:
BindingList<partner> partnerList = _context.partner.Local.ToBindingList();
this._view.PartnerDatasource.DataSource = partnerList;
This is a datasource for a drop down menu. What I want is to put a specific item to show as first item in a drop down. I tried something like this:
public void Swap<T>(IList<T> list, int indexA, int indexB)
{
T tmp = list[indexA];
list[indexA] = list[indexB];
list[indexB] = tmp;
}
and then:
this.Swap(partnerList, 0, partnerList.Count - 1);
This works when it comes to swapping, but it somehow messes up entity framework completely and I get various errors further on when I try to use these entities (partner)...
What would an appropriate way to do the this?
var names = new [] { "Alice", "Bob", "Charlie", "Dave", "Eve" };
var specialName = "Eve";
var sortedNames = names.OrderByDescending(x => x == specialName);
foreach (var name in sortedNames)
Console.WriteLine(name);
Result:
Eve
Alice
Bob
Charlie
Dave