What the best way to wire up Entity Framework database context (model) to ViewModel in MVVM WPF?
Posted
by
hal9k2
on Programmers
See other posts from Programmers
or by hal9k2
Published on 2013-10-04T11:04:14Z
Indexed on
2013/10/24
10:10 UTC
Read the original article
Hit count: 274
As in the question above: What the best way to wire up Entity Framework database model (context) to viewModel in MVVM (WPF)?
I am learning MVVM pattern in WPF, alot of examples shows how to implement model to viewModel, but models in that examples are just simple classes, I want to use MVVM together with entity framework model (base first approach). Whats the best way to wire model to viewModel.
Thanks for answers.
//ctor of ViewModel
public ViewModel()
{
db = new PackageShipmentDBEntities(); // Entity Framework generated class
ListaZBazy = new ObservableCollection<Pack>(db.Packs.Where(w => w.IsSent == false));
}
This is my usual ctor of ViewModel, think there is a better way, I was reading about repository pattern, not sure if I can adapt this to WPF MVVM
© Programmers or respective owner