views:

284

answers:

1

In a previous question on Stack Overflow, I had run into an issue with returning an EF query to the DataGridView. Of course I'd run into an issue. However, I added an extension method that still has me baffled since it isn't working. It seems like it should, but for some reason it's not.

public static class BindingListEntityExtension
{
    public static BindingList<T> ToBindingList<T>(this IEnumerable<T> entities)
    {
        BindingList<T> rtn = new BindingList<T>();

        foreach (T obj in entities)
        {
            rtn.Add(obj);
        }

        return rtn;
    }
}

Any ideas what's going on? My implementation is like so:

MyEntities context = new MyEntities();
tempDataGridView.DataSource = context.Employees.ToBindingList();
A: 

Got it. As Ecyrb had suggested in a previous post, the BindingList does not sort. I did use the suggested site/ to get my list to sort. Thanks guys! My extension does work now.

Jason N. Gaylord