Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
335
WinGrid databinding with Entity Framework
posted

Hello, I am trying to bind a WinGrid to my simple Entity Framework CodeFirst data. I created a few simple models, a DBContext, an implementation of a generic Repository Pattern and a UnitOfWork DataaccessLayer to access my database.

But I'm having problems binding the grid to it, as all the datasources somehow do not work and the EntityDataSource does not exist anymore in the latest EF/.NET version. The only way that seems to work, is to surpass the repository and access the DbSet directly:

grid.DataSource = dal.getContext().Students.Local.ToBindingList();

dal is an object of a class containing all the repositories, and getContext returns the DBContext containing all the DbSet's.

It works, but it feels rather....dirty. Usually, the Entity Framework offers such amazing and simple features, but binding to Controls (not only infragistics) seems to be a huge pain. Is there really no way to use visual binding and automatically generated Data/column schemes and all that stuff I had with old ado.net datasets?