ive been working on trying to convert a list into a IEnumerable<>, passing in my Service Reference with my table in my database. i needed to convert the IEnumerable to a list of strings in the beginning, so that i could use the Sort() function, but now im trying to convert it back to a IEnumerable so i can use it as a Itemsource for my combobox. Any ideas how to do this?

im using Silverlight 5 and WCF RIA Services, using LINQ to SQL, and using the C# language.

code is below that i have so far, but nothing i have found online has been able to convert back to a IEnumerable.

ServiceReference1.LoginInfo is my table in my database.

         IEnumerable<ServiceReference1.LoginInfo> list = e.Result as IEnumerable<ServiceReference1.LoginInfo>;

        string comboname;

        List<string> items = new List<string>();

        for (int i = 0; i < list.Count(); i++)
        {

             comboname = list.ElementAt(i).UserName;
             items.Add(comboname);
             items.Sort();

        }

        //This is where i need something to convert the list<string> items to the IEnumerable<ServiceReference1.LoginInfo> list


         //set the itemsource      

        RegisterPanel_CarrierComboBox.ItemsSource = list;

the main reason im trying to turn this list of strings into a ienumerable again is because i need to be able to set it to my itemsource, to make my combobox work correctly. once this is all set ill be able to work on the next problem of why my combobox wont clear when i switch to another stackpanel.

any and all answers will be helpful. thank you

1

There are 1 answers

1
George Vovos On BEST ANSWER

From what I understand from your code you just want to sort your list of LoginInfo by username. Correct?

        IEnumerable<LoginInfo> list = ...
        list = list.OrderBy(t => t.username).ToList();