App sample

Is there a Winforms sample (i.e. more then Console.WriteLine statements), using the objects or projecting into business objects or something and how they lay that out and maintain client object state TIA.


Answer this question

App sample

  • mikeymay

    If you are projecting the entire object from your query, you should be able to bind to it ok. For example, I put a standard DataGridView on a form with it's Binding Source. I then put the following code in the Form Load:

    Dim Emps As List(Of LinqBo.Employee) = LinqBo.EmployeeList.GetEmployeeList
    Dim results = Select e _
    From e In Emps _
    Order By e.FirstName
    Me.EmployeeListBindingSource.DataSource = results

    The grid binds fine and the propertys are updated as necessary. Naturally, you would need to implement the update methods to persist the changes. The issue comes with queryies that use inferred types such as the following:

    Dim results = Select e.FirstName, e.LastName, e.Orders, e.Orders.Count _
    From e In Emps _
    Order By it.Count Descending

    In this case, the grid can't bind properly to the list as it is return a new IEnumerable< > where is an unknown item. Also, the grid wants more than just IEnumerable<T> for binding as I understand it. I asked at one of the LINQ chats a while back about the binding issue and the response was that they were interested in making binding work well, but didn't have much guidance more than that at the time. They are probably working on it, but time will tell.

    Jim Wooley
    http://devauthority.com/blogs/jwooley



  • David Right

    Any idea on when the next drop will be I'm about to do a series of LINQ presentations for code camps and UG meetings and would like to have an idea other than just sometime this spring.Feel free to respond offline at jimwooley at hotmail dot com.

  • Bu Shaz

    DLINQ will have databinding samples in the next preveiw. We will be implementing some of the interfaces needed for binding to Winforms controls such as grids. Currently, databinding works OK in a readonly scenario; but as Jim said; you need to perform the update logic on your own, at least for now.

    tadam - MSFT



  • App sample