views:

704

answers:

3

1) Binding to The following populates a READ ONLY WinFrms grid:

    Dim query = (From profile _
              In db.profile _
              Where profile.employee.employeeId = employeeID _
              Select profile.description)

    Me.DataGridView.DataSource = profileQueryList

2) Binding to the entity itself makes the WinForms grid EDITABLE, but unfiltered:

    Me.DataGridView.DataSource = db.profile

I need something that combines the filtering feature of #1 with the editable feature of #2.

A: 

Try to use an explicit ToList() call.

Me.DataGridView.DataSource = query.ToList()

I guess that else only the expression tree of the query is bound and the entities are only fetched on demand.

Daniel Brückner
ToList still results in a read only grid.
Jeff
Have you tried inserting a BindingSource between control and collection?
Daniel Brückner
yes. same read-only result.
Jeff
A: 

Don't bind directly to the queryable. Instead, you need to go through the EntityDataSource class. Note, especially, this article on how to filter data with this control.

Craig Stuntz
EntityDataSource is part of System.Web.UI.Webcontrols. I'm working in a Winforms environment. Is there an equivilent?
Jeff
A: 

Found the solution! It's documented in:
http://stackoverflow.com/questions/784363/linq-to-entities-filtering-an-entity-dyamic-strongly-typed

Jeff