none
Binding interfaces supported by EF4 RRS feed

  • Question

  • Hello folks, I've just come over from the ozDotNet mailing list where there is little discussion of EF4.

     

    In my 3-tier apps I often send non-tracked materialized collections up to the UI where they used in grids and pickers. The collections usually contain Complex Types made with a SELECT VALUE query.

     

    I only have the option of materializing the query with ToArray or ToList, which results in collections that are very poorly featured compared to their System.Data equivalents DataSet, DataTable, DataView and DataRow. The System.Data classes support many interfaces which allow grid sorting, fast SQL-like filter expressions and begin/end edit semantics. The EF4 entity and complex type classes do not implement the required interfaces, nor is there support for materializing anything but arrays and lists.

     

    To workaround this I have been manually converting the raw DbDataRecord results into strongly-typed DataSets for return to the UI where I get really convenient sorting, filtering and editing.

     

    It seems stupid to have to pull data back in EF4 and then convert it back to old fashioned DataSets to get all the binding interfaces I want, but this is my workaround. Is there a better technique I'm not aware of?

     

    Greg Keogh

    Wednesday, July 20, 2011 8:25 AM

Answers

All replies

  • Hi Greg,

    Welcome!

    According to your description, I'm not sure what type of your appliction.

    For web, you can use EntityDataSource: http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/2a1ebec8-5d70-4e4d-ae87-a7b350854196

    For WinForm, you can add object data Source: http://blogs.msdn.com/b/adonet/archive/2011/02/16/ef-feature-ctp5-code-first-and-winforms-databinding.aspx

    If the reply could't give you any help, please feel free to let me know, thanks for understanding.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, July 21, 2011 7:36 AM
    Moderator
  • Hi Greg,

    I am writing to check the status of the issue on your side. Would you mind letting us know the result of the suggestions?

    If you need further assistance, please feel free to let me know. I will be more than happy to be of assistance.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, July 26, 2011 6:00 AM
    Moderator
  • Sorry for the late reply, I thought I would get email notifications of replies, but I didn't.

    I forgot to specify back on July 20 that my scenario is mostly related to WinForms, although the issue of EF4 query result collections and binding interfaces is a general one.

    I am only talking about sending materialized collections of classes back from the EF4 context to the UI. The context has been used and disposed. Using XXXDataSource classes as you mention is useless in a multi-tiered app because they bind the UI directly to the data source.

    In the early ADO.NET days I would Fill a DataSet and send it back, and I was very happy with the large number of interfaces supported by the ADO.NET classes, such a IEditableObject and sortable binding. I should also mention that the collection and entity classes generated by the netTiers templates are at least as fully featured as the ADO.NET classes.

    With EF4 I only seem to have the option of materializing and sending back T[] arrays or List<T> of objects. These collections are poorly featured compared to both the ADO.NET classes and the netTiers clases. As a result of this, I have been converting EF4 query results back to old fashioned DataSets to send back to the UI for binding.

    It just seemed silly to be using a brand new product (EF4) and then converting its query results back into old fashioned DataSets to return to the UI. I was hoping that perhaps I'd missed some clever technique to make things easier.

    Greg

    Wednesday, August 3, 2011 9:10 AM