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");
        }
Exemple #2
0
        public void RemoveMapping(ScalarProperty property, SSDL.EntityType.EntityType table)
        {
            if (property == null)
            {
                throw new ArgumentNullException();
            }

            if (!Mapping.ContainsKey(property))
            {
                return;
            }
            var propertyMapping = Mapping[property];

            switch (propertyMapping.Count)
            {
            case 0:
                return;

            case 1:
                if (propertyMapping.Keys.First() == table)
                {
                    Mapping.Remove(property);
                }
                break;

            default:
                if (propertyMapping.ContainsKey(table))
                {
                    propertyMapping.Remove(table);
                }
                break;
            }
            EntityType.Mapping.OnPropertyChanged("IsCompletlyMapped");
        }
 protected override void AddTableMapped(SSDL.EntityType.EntityType table)
 {
     base.AddTableMapped(table);
     if (!SSDLTables.Contains(table))
     {
         SSDLTables.Add(table);
     }
 }
Exemple #4
0
 public IEnumerable <PropertyMapping> GetSpecificMappingForTable(SSDL.EntityType.EntityType table)
 {
     return(from mapping in Mapping
            where mapping.Value.Keys.Any(key => key == table)
            select new PropertyMapping {
         Property = mapping.Key, Column = mapping.Value[table]
     });
 }
Exemple #5
0
        public IEnumerable <PropertyMapping> GetMappingForTable(SSDL.EntityType.EntityType table)
        {
            var value       = GetSpecificMappingForTable(table);
            var baseMapping = BaseMapping;

            if (baseMapping != null)
            {
                value.Union(baseMapping.GetMappingForTable(table));
            }
            return(value);
        }
Exemple #6
0
 public IEnumerable <PropertyMapping> this[SSDL.EntityType.EntityType table]
 {
     get
     {
         return(from csdlProp in Mapping.Keys
                let ssdlProp = Mapping[csdlProp].FirstOrDefault(ssdlI => ssdlI.Key == table).Value
                               where ssdlProp != null
                               select new PropertyMapping {
             Property = csdlProp, Column = ssdlProp
         });
     }
 }
Exemple #7
0
 public SSDL.Property.Property this[ScalarProperty scalarProperty, SSDL.EntityType.EntityType table]
 {
     get
     {
         var columns = this[scalarProperty];
         if (columns == null)
         {
             return(null);
         }
         if (columns.ContainsKey(table))
         {
             return(columns[table]);
         }
         return(null);
     }
     set
     {
         if (value == null)
         {
             if (Mapping.ContainsKey(scalarProperty))
             {
                 Mapping[scalarProperty].Remove(table);
             }
         }
         else if (Mapping.ContainsKey(scalarProperty))
         {
             var columns = Mapping[scalarProperty];
             if (columns.ContainsKey(table))
             {
                 columns[table] = value;
             }
             else
             {
                 columns.Add(table, value);
                 AddTableMapped(table);
             }
         }
         else
         {
             Mapping.Add(scalarProperty, new Dictionary <SSDL.EntityType.EntityType, SSDL.Property.Property>()
             {
                 { table, value }
             });
             AddTableMapped(table);
         }
         EntityType.Mapping.OnPropertyChanged("IsCompletlyMapped");
     }
 }
        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");
        }
        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);
        }
Exemple #10
0
 protected virtual void AddTableMapped(SSDL.EntityType.EntityType table)
 {
     EntityType.Mapping.OnPropertyChanged("IsCompletlyMapped");
 }
Exemple #11
0
 void IMapping.RemoveMapping(ScalarProperty property, SSDL.EntityType.EntityType table)
 {
     RemoveMapping(property);
 }
Exemple #12
0
 public IEnumerable <PropertyMapping> GetSpecificMappingForTable(SSDL.EntityType.EntityType table)
 {
     return(this.Where(pm => pm.Column.EntityType == table));
 }