Question

I'm starting on a small windows forms project that makes extensive use of editable grids. I want to use Linq to Entities, but while it's trivial to bind a grid to the Linq query it's read-only. I couldn't figure out a good way to have an editable grid that auto-updates the database. (I hacked a work-around where I copy the data into a dataset for display/update and translate back... ugly!)

So for now I've decided to forget Linq to Entities and use the old table adapter/dataset method from 2.0.

Is there a compelling reason why I should use Linq to Entities instead? Is there a way to do editable grids that I just missed?

Was it helpful?

Solution 2

Found the solution: use lambda expressions to filter the entity, then bind directly to the entity. Works great.

OTHER TIPS

You can just bind an entity collection returned by a query to an control and this will allow editing the bound entities. May be you should insert a BindingSource between collection and control, but that depends. If you call SaveChanges() on the object context the changes are persisted to the database. So data binding with the Entity Framework definitly works.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top