locked
Linq query for wpf datagrid binding RRS feed

  • Question

  • I am trying to develop a program I wrote for my work in winforms with WPF. I have come across a problem when trying to fill the WPF datagrid. 

    To try and explain, the first image is a snapshot of the material planner datagrid in the original winforms program and the second image is the database structure from the edmx file. The user selects a date range, and the program displays the planning for the material (laptops, screens, printers, etc.). The brown colour on the planner indicates an item in transport to/from an event and orange for when it is being used in that event. The number in the cell is the mission number. The user can add or remove items from events. It works well for our needs. The red circle shows which tables I have used.

    To fill the cells with the colours and numbers I ran through about 300 lines of code – but it works. In WPF, datagrids use bindings and here is where I come unstuck. My question is, is it possible to create a query that can include user selected dates that are not in the database? I want to use these dates to create the columns. I have been asking for help in the WPF forum  but I have been unable to get the suggestions to work. I really do need to find a way to achieve this.

    Thanks for any help. I can provide code if needed.  

     


    :-( Still trying to program

    Wednesday, December 31, 2014 12:10 PM

Answers

  • My question is, is it possible to create a query that can include user selected dates that are not in the database? I want to use these dates to create the columns.

    If you were to disconnect from EF by using DTO(s) in a List<T>, really that's all EF is doing is using a collection of objects, then you would just query the DTO(s) in  the List<T>. You can make a new DTO, populate it and add it to the List<DTO>. You bind the List<DTO> to the grid. You can also have a List<t> of DTO(s) in the parent DTO, the children objects.

    • Marked as answer by Jonsey Tuesday, January 13, 2015 5:42 AM
    Wednesday, December 31, 2014 4:43 PM

All replies

  • My question is, is it possible to create a query that can include user selected dates that are not in the database? I want to use these dates to create the columns.

    If you were to disconnect from EF by using DTO(s) in a List<T>, really that's all EF is doing is using a collection of objects, then you would just query the DTO(s) in  the List<T>. You can make a new DTO, populate it and add it to the List<DTO>. You bind the List<DTO> to the grid. You can also have a List<t> of DTO(s) in the parent DTO, the children objects.

    • Marked as answer by Jonsey Tuesday, January 13, 2015 5:42 AM
    Wednesday, December 31, 2014 4:43 PM
  • Thank you for your reply darnold924. I have started working on what you have suggested. My first challenge is to set the dates as the column headers. I think the only way to achieve this is to add the columns in xaml dynamically as the user chooses the dates. Once I have done that I will try and hook everything else up.

    :-( Still trying to program

    Sunday, January 4, 2015 2:04 PM