private void AddNotNullCondition(SSDL.Property.Property column) { if (!Mapping.ConditionsMapping.Any(ccm => ccm.Column == column && ccm.Operator == ConditionOperator.IsNotNull)) Mapping.ConditionsMapping.Add(new ColumnConditionMapping { Column = column, Operator = ConditionOperator.IsNotNull, Generated = true }); }
private void RemoveNotNullCondition(SSDL.Property.Property column) { var columnConditionMapping = Mapping.ConditionsMapping.FirstOrDefault(ccm => ccm.Column == column && ccm.Operator == ConditionOperator.IsNotNull && ccm.Generated); if (columnConditionMapping != null) Mapping.ConditionsMapping.Remove(columnConditionMapping); }
protected override void AddTableMapped(SSDL.EntityType.EntityType table) { base.AddTableMapped(table); if (!SSDLTables.Contains(table)) SSDLTables.Add(table); }
private bool RemoveSSDLTableToComplexProperty(ComplexProperty complexProperty, MappingBase mapping, SSDL.EntityType.EntityType ssdlTable) { bool deleteAll = true; foreach (var prop in mapping.Mapping.Keys.ToList()) { var propMapping = mapping.Mapping[prop]; if (propMapping.Count == 1) mapping.RemoveMapping(prop); else { propMapping.Remove(ssdlTable); deleteAll = false; } } foreach (var complexProp in mapping.ComplexMapping.Keys.ToList()) if (RemoveSSDLTableToComplexProperty(complexProp, mapping.ComplexMapping[complexProp], ssdlTable)) mapping.ComplexMapping.Remove(complexProp); else deleteAll = false; return deleteAll; }
private void RemoveSSDLTable(SSDL.EntityType.EntityType ssdlTable) { if (MappingInit) return; foreach (var prop in Mapping.Keys.ToList()) { var propMapping = Mapping[prop]; if (propMapping.Count == 1) Mapping.Remove(prop); else propMapping.Remove(ssdlTable); } foreach (var complexProp in ComplexMapping.Keys.ToList()) if (RemoveSSDLTableToComplexProperty(complexProp, ComplexMapping[complexProp], ssdlTable)) ComplexMapping.Remove(complexProp); OnPropertyChanged("IsCompletlyMapped"); }
private bool TryToAddSSDLColumnToComplexProperty(ComplexProperty complexProperty, Func<MappingBase> mapping, SSDL.Property.Property column) { var prop = complexProperty.ComplexType.ScalarProperties.FirstOrDefault(p => p.Name == column.Name); if (prop != null) { mapping().AddMapping(prop, column); return true; } foreach (var complexProp in complexProperty.ComplexType.ComplexProperties) if (TryToAddSSDLColumnToComplexProperty(complexProp, () => { var complexMapping = mapping().ComplexMapping; if (complexMapping.ContainsKey(complexProp)) return complexMapping[complexProp]; var complexPropMapping = new ComplexPropertyMapping(EntityType, complexProp); complexMapping.Add(complexProp, complexPropMapping); return complexPropMapping; }, column)) return true; return false; }
private void AddSSDLTable(SSDL.EntityType.EntityType ssdlTable) { if (MappingInit || ssdlTable == null) return; foreach (var column in ssdlTable.Properties) { var prop = EntityType.ScalarProperties.Union(EntityType.Keys).FirstOrDefault(p => p.Name == column.Name); if (prop == null) { foreach (var complexProp in EntityType.ComplexProperties) if (TryToAddSSDLColumnToComplexProperty(complexProp, () => { if (ComplexMapping.ContainsKey(complexProp)) return ComplexMapping[complexProp]; else { var subComplexMapping = new ComplexPropertyMapping(EntityType, complexProp); ComplexMapping.Add(complexProp, subComplexMapping); return subComplexMapping; } }, column)) break; } else AddMapping(prop, column); } OnPropertyChanged("IsCompletlyMapped"); }