none
bindingsource ui and entity framework 6 RRS feed

  • Question

  • Hello.
    I started to study the WPF,
    1) in the data part, I saw several examples and use objects to store other data to list observablelist to enumerable etc ....
    It 'a difference by architectural reasons or just from the date of application and change of entity framework? I use Entity Framework 6.
    what are the collections that it is better to use, in short if the speech is complex.
    2) In the ui part I use the DevExpress objects but what I do not understand is that until now with win forms I used the BindingSource and relationships (the DataRelation) I do not see more in no instance even if on a book by entity framework She teaches how to use it.
    Again , this choice is in the architectural or not?
    Because with data relations was simple create multi detail grid , but in entity framework there are the associations....can work as the relations in entity framwork?
    bindingsource or not?

    thank you.
    Thursday, April 28, 2016 3:07 PM

Answers

  • Hi Giuseppe,

    I'm not sure I follow your questions exactly.

    Maybe that doesn't matter too much though.

    WPF is very different to windows forms and there is no direct equivalent to BindingSource.

    The ItemsSource of an intemscontrol is used to bind a collection.

    Most wpf devs use the MVVM pattern and don't bind directly to data from entity framework.

    In small to mid sized applications a common approach is to "wrap" each entity with a ViewModel.

    Usually you want some business and or UI logic or something and you don't want to pollute the entity objects with that.

    Use ObservableCollection<t>.

    .

    There are no books which explain MVVM very well. Not that I've seen.

    Books which explain entity framework are not going to be written by wpf experts.

    I have a series which starts to explain a way to work with entity framework and WPF. The first 2 steps in this are done. I should mention they don't really cover Parent - Child scenarios.

    There's a lot to cover and I've not got that far with them yet.

    You might find them interesting though:

    http://social.technet.microsoft.com/wiki/contents/articles/28209.wpf-entity-framework-mvvm-walk-through-1.aspx

    https://gallery.technet.microsoft.com/WPF-Entity-Framework-MVVM-78cdc204


    Hope that helps.

    Technet articles: WPF: Layout Lab; All my Technet Articles

    Friday, April 29, 2016 8:43 AM
    Moderator
  • Entity Framework is an object-relational mapper that eliminates the need to write data-access code. It belongs in the data access layer (DAL). WPF and Windows Forms are UI frameworks for building desktop applications on Windows. Two totally different things. A UI should not be dependent on any data access layer or data access technology in an enterprise architecture.

    In an enterprise scenario, you typically use a service or/and a business layer in between the UI client application and the DAL. The DAL may or may not use Entity Framework to read data from a database but the client is totally unaware and uninterested of whether Entity Framework is actually involved.

    In WPF you use an ObservableCollection whenever you want to provide notifications when items get added or removed to and from the collection respectively: https://msdn.microsoft.com/en-us/library/ms668604(v=vs.110).aspx. This has nothing to do with Entity Framework. The ObservableCollection class belongs in the UI layer only. The benefit of using an ObservableCollection<T> over another collection such as List<T> is that it implements the INotifyCollectionChanged interface and this means that WPF will update any data bound UI control automatically as items are added or removed from the source collection. Please refer to the link above for more information.

    Hope that helps.

    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

    Sunday, May 1, 2016 10:51 AM

All replies

  • Hi giuseppe ferrrari,

    According to your description, it's more related to WPF, we help you move it to WPF forum for better support.

    Thank you for your understanding.

    Best regards,

    Cole Wu


    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.

    Friday, April 29, 2016 7:45 AM
    Moderator
  • Hi Giuseppe,

    I'm not sure I follow your questions exactly.

    Maybe that doesn't matter too much though.

    WPF is very different to windows forms and there is no direct equivalent to BindingSource.

    The ItemsSource of an intemscontrol is used to bind a collection.

    Most wpf devs use the MVVM pattern and don't bind directly to data from entity framework.

    In small to mid sized applications a common approach is to "wrap" each entity with a ViewModel.

    Usually you want some business and or UI logic or something and you don't want to pollute the entity objects with that.

    Use ObservableCollection<t>.

    .

    There are no books which explain MVVM very well. Not that I've seen.

    Books which explain entity framework are not going to be written by wpf experts.

    I have a series which starts to explain a way to work with entity framework and WPF. The first 2 steps in this are done. I should mention they don't really cover Parent - Child scenarios.

    There's a lot to cover and I've not got that far with them yet.

    You might find them interesting though:

    http://social.technet.microsoft.com/wiki/contents/articles/28209.wpf-entity-framework-mvvm-walk-through-1.aspx

    https://gallery.technet.microsoft.com/WPF-Entity-Framework-MVVM-78cdc204


    Hope that helps.

    Technet articles: WPF: Layout Lab; All my Technet Articles

    Friday, April 29, 2016 8:43 AM
    Moderator
  • Entity Framework is an object-relational mapper that eliminates the need to write data-access code. It belongs in the data access layer (DAL). WPF and Windows Forms are UI frameworks for building desktop applications on Windows. Two totally different things. A UI should not be dependent on any data access layer or data access technology in an enterprise architecture.

    In an enterprise scenario, you typically use a service or/and a business layer in between the UI client application and the DAL. The DAL may or may not use Entity Framework to read data from a database but the client is totally unaware and uninterested of whether Entity Framework is actually involved.

    In WPF you use an ObservableCollection whenever you want to provide notifications when items get added or removed to and from the collection respectively: https://msdn.microsoft.com/en-us/library/ms668604(v=vs.110).aspx. This has nothing to do with Entity Framework. The ObservableCollection class belongs in the UI layer only. The benefit of using an ObservableCollection<T> over another collection such as List<T> is that it implements the INotifyCollectionChanged interface and this means that WPF will update any data bound UI control automatically as items are added or removed from the source collection. Please refer to the link above for more information.

    Hope that helps.

    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

    Sunday, May 1, 2016 10:51 AM
  • Very thanks.now i must understands model and dal and repository.

    I would use entity framework 6.

    Have some new links?

    Thanks.

    Thursday, May 5, 2016 8:50 AM
  • Please only ask one question per thread. And please ask Entity Framework related questions in the EF forum: https://social.msdn.microsoft.com/Forums/en-US/home?forum=adodotnetentityframework.

    You could refer to my blog post about how to implement a generic data access layer in Entity Framework for some ideas on how use Entity Framework in an N-tier architecture: https://blog.magnusmontin.net/2013/05/30/generic-dal-using-entity-framework/.

    Please close this thread by marking all helpful posts as answer and then start a new thread in an appropriate forum if you have a new question. Once again, please don't ask several questions in the same thread.

    Thursday, May 5, 2016 9:00 AM
  • Sorry i understand
    Thursday, May 5, 2016 9:02 AM
  • In my experience.

    Entity framework acts as a repository.

    There's little point in introducing another layer in small to mid sized applications.

    Sure, if you have some huge app with many users and you need an enterprise service bus architecture then DTO are necessary.

    I really hope you're not building one of those as your first WPF project though.


    Hope that helps.

    Technet articles: WPF: Layout Lab; All my Technet Articles

    Thursday, May 5, 2016 9:10 AM
    Moderator