none
ToBindingList does not support Filter and Sort properties RRS feed

  • Question

  • This is an old known problem - but we are trying to convert our existing code to use Entity Framework 6.0.  This works well until we start to use extended functionality like the DataGridViewAutoFilterComboBoxColumn.  This works fine with a BindingSource against a Dataset.  It does not work at all with an BindingSource created by using the .ToBindingList.  The column control checks if the underlying binding source supports filtering, and if it does not, then you cannot filter by the values in a column.  Our users have come to expect this mechanism as a convenient and space-efficient way to filter the contents of a grid.

    I have tried several solutions available on the web for creating custom bindinglists, but they all seem to have been written prior to .Net 4.0 and the code breaks when I try and use it.

    Many people have also suggested using Linq queries - but the DataGridViewAutoFilterComboBoxColumn does not support that.  It expects to put in a string to the filter and have it parsed, e.g. "CategoryID=56". 

    Does anyone have a workaround that solves this problem? Either I need a Filter Column that understands EF and linq, or a BindingSourceView that understands EF and provides filtering.

    Also, why does Microsoft (or possibly the team working on the Entity Framework) not simply extend the EF binding source returned by the ToBindingList to support this obviously needed functionality?

    Thanks, Neil


    Neil M. Johnson

    Tuesday, October 14, 2014 5:41 PM

Answers

  • Hello Neil,

     >>Does anyone have a workaround that solves this problem? Either I need a Filter Column that understands EF and linq, or a BindingSourceView that understands EF and provides filtering.

    I am not quite sure what you are looking for, if you look for custom controls, which could understand EF and provides filtering, this is beyond the scope of our support for this form, I suggest that you could post it to:

    https://social.msdn.microsoft.com/Forums/windows/en-US/home?forum=winformsdatacontrols

    If you are looking for an implementation from Entity Framework which could support the sorting in windows form. You could check the article below:

    Databinding with WinForms

    It provides a way to return a collection enable two-way data binding with sorting.

    >> Also, why does Microsoft (or possibly the team working on the Entity Framework) not simply extend the EF binding source returned by the ToBindingList to support this obviously needed functionality?

    Being not sure if the team do that for some specific reasons since there is not clear document. If you want the Entity Framework contains such a function, you could post a wish to:

    https://data.uservoice.com/forums/72025-entity-framework-feature-suggestions

    And vote it so that the team might consider adding it to the next released version.

    Regards,

    Fred.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, October 15, 2014 2:46 AM
    Moderator