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");
        }
 public void RemoveTPCMapping()
 {
     foreach (var scalarProp in Mapping.Keys.Where(sp => !sp.IsKey).Except(EntityType.ScalarProperties).ToList())
     {
         Mapping.Remove(scalarProp);
     }
     foreach (var complexProp in ComplexMapping.Keys.Except(EntityType.ComplexProperties).ToList())
     {
         ComplexMapping.Remove(complexProp);
     }
 }
        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");
        }