- private agsEntities agsEntities = new agsEntities(connectionstring);
- public ObservableCollection<FAMILY> FamilyCollection.....
- ..........INotify
- public ObjectQuery<FAMILY> FamiliesQuery;
- // FAMILY class is defined as: public partial class FAMILY : EntityObject
- // mostly this was autocreated by EF
- public ObjectQuery<FAMILY> GetFAMILIESQuery(agsEntities agsEntities)
- {
- ObjectQuery<FAMILY> fAMILIESQuery = agsEntities.FAMILIES;
- return fAMILIESQuery;
- }
- private CollectionViewSource _familiesViewSource;
- public CollectionViewSource FamiliesViewSource
- {
- get
- {
- if (_familiesViewSource == null)
- GetFamilyViewSource();
- return _familiesViewSource;
- }
- }
- private void GetFamilyViewSource()
- {
- // Load data into FAMILIES
- //this is ObjectQuery<T>
- this.FamiliesQuery = this.GetFAMILIESQuery(this.agsEntities);
- //this is a CollectionViewSource......
- this._familiesViewSource = new CollectionViewSource();
- //this is an ObjectResult<T>
- this._familiesViewSource.Source = this.FamiliesQuery.Execute(MergeOption.AppendOnly);
- //refresh the view (in this case a DataGrid is bound to FamiliesViewSource
- this._familiesViewSource.View.Refresh();
- //and into an observable collection just in case
- //agsEntities.FAMILIES is defined by EF as: public ObjectSet<FAMILY> FAMILIES
- foreach (FAMILY thing in agsEntities.FAMILIES)
- FamilyCollection.Add(thing);
- }
Saturday, September 6, 2014
Some overview of Entity Framework implementation
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment