/// <summary> /// Reconciles the crosswalk from data context. /// </summary> public void ReconcileCrosswalkFromDataContext() { var prov = ServiceLocator.Current.GetInstance <IDomainSessionFactoryProvider>(); using (var session = prov.SessionFactory.OpenSession()) { foreach (var model in DataContextObject.CrosswalkCache) { var xwalk = MappedFieldModels.FirstOrDefault(field => string.Equals(field.Element.Name, model.ElementName, StringComparison.OrdinalIgnoreCase)); if (xwalk != null) { foreach (var xwalkModel in model.Mappings) { var scope = xwalk.CrosswalkModels.FirstOrDefault(x => Equals(x.Crosswalk.SourceValue, xwalkModel.Source)); if (scope != null) { var temp = (from thisScopeValue in session.Query <ScopeValue>() join thisScope in session.Query <Scope>() on thisScopeValue.Owner.Id equals thisScope.Id where thisScope.Id == xwalk.Element.Scope.Id && thisScopeValue.Value == xwalkModel.Value select thisScopeValue).FirstOrDefault(); scope.Crosswalk.ScopeValue = temp; } } } } } }
/// <summary> /// Applies the source fields. /// </summary> private void ApplySourceFields() { var entries = MappedFieldModels.Where(model => model != null).Select(model => model.FieldEntry.Column.ColumnName).ToList(); entries.Insert(0, string.Empty); SourceFields = (ListCollectionView)CollectionViewSource.GetDefaultView(new ObservableCollection <string>(entries)); ElementFilterChangedCommand = new DelegateCommand(() => { MappedFieldEntries.Filter = o => ElementEntryMatchesFilter(o, CurrentElementFilter); }); }
/// <summary> /// Returns true if ... is valid. /// </summary> /// <returns></returns> public override bool IsValid() { return(MappedFieldModels.SelectMany(model => model.FieldEntry.Bin).All(item => item.ScopeValue == null)); }