Closed rowanmiller closed 9 years ago
@rowanmiller - Can you suggest exception message for this?
Eww... another reason to cross-compile to net45
@smitpatel Here's what we had in EF6:
Data binding directly to a store query (DbSet, DbQuery, DbSqlQuery, DbRawSqlQuery) is not supported. Instead populate a DbSet with data, for example by calling Load on the DbSet, and then bind to local data. For WPF bind to DbSet.Local. For WinForms bind to DbSet.Local.ToBindingList(). For ASP.NET WebForms you can bind to the result of calling ToList() on the query or use Model Binding, for more information see http://go.microsoft.com/fwlink/?LinkId=389592.
It threw NotSupportedException
.
Caveat: There is no DbSet.Local in EF7, at least not yet. Without it databinding is mostly manual, e.g. you can do .ToList()
and then somehow make sure any items added or removed are added and removed on the context as well.
Moreover, without DbSet.Local the value of throwing an exception here is:
IListSource.GetList()
) more than once Proposed message:
Data binding directly to a store query is not supported. Instead materialize the results into a collection, by calling a method such as ToList() or ToArray(), and bind to the collection. This should be done to avoid sending a query to the database each time the databound control iterates the data.
Obviously we can add more info when we improve our databinding story (i.e. implement .Local).
@ajcvickers : What does the label "type-unknown" mean? Will this be implemented that WPF-Controls can bind to a DBSet? We run to this issue because we are porting from 4.8 to core 7 and we have a lot of scenarios where we directly query the database without caching it to a temporary list.
@DamirLisak No, this is by-design. Binding directly to the DbSet is a pit-of-failure because it causes a database query every time the set is enumerated. See Getting Started with WPF.
In EF6 we implemented IListSource to throw and point folks to the right way to data bind. We should consider doing this again.