public void UpdateModelViews(ModelViewSerializable mvs) { if (ModelViews == null) { ModelViews = new ObservableCollection <ModelViewSerializable>(); } if ((mvs != null) && (SelectedEntity != null) && (CurrentDbContext != null)) { if (mvs.RootEntityFullClassName == SelectedEntity.CodeElementFullName) { if (CurrentDbContext.ModelViews != null) { ModelViewSerializable result = CurrentDbContext.ModelViews.FirstOrDefault(m => m.ViewName == mvs.ViewName); if (result != null) { if (!ModelViews.Any(m => m.ViewName == mvs.ViewName)) { ModelViews.Add(mvs); } } } } } OnPropertyChanged("SelectedEntity"); }
public void OnForeignKeySelected(ModelViewForeignKey foreignKey) { if (ModelViews == null) { ModelViews = new ObservableCollection <ModelViewSerializable>(); } if (foreignKey == null) { ModelViews.Clear(); return; } if (ModelViews.Any(mv => ((mv.RootEntityFullClassName != foreignKey.NavigationEntityFullName) || (mv.RootEntityUniqueProjectName != foreignKey.NavigationEntityUniqueProjectName)))) { ModelViews.Clear(); } if (CurrentDbContext == null) { return; } if (CurrentDbContext.ModelViews == null) { return; } List <ModelViewSerializable> result = CurrentDbContext.ModelViews .Where(mv => (mv.RootEntityFullClassName == foreignKey.NavigationEntityFullName) && (mv.RootEntityUniqueProjectName == foreignKey.NavigationEntityUniqueProjectName)) .ToList(); if (result != null) { if (result.Count != ModelViews.Count) { result.ForEach(r => { if (!ModelViews.Any(mv => mv.ViewName == r.ViewName)) { ModelViews.Add(r); } }); } } }