示例#1
0
 protected virtual void OnChanged(ScalarProperty property, SSDL.Property.Property oldColumn, SSDL.Property.Property newColumn)
 {
     if (Changed != null)
     {
         Changed(property, oldColumn, newColumn);
     }
     OnCollectionChanged();
 }
示例#2
0
 protected virtual void OnAdded(ScalarProperty property, SSDL.Property.Property column)
 {
     if (Added != null)
     {
         Added(property, column);
     }
     OnCollectionChanged();
 }
示例#3
0
        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);
            }
        }
示例#4
0
 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
         });
     }
 }
示例#5
0
        private void MappingAdded(SSDL.Property.Property column)
        {
            var associationMapping = NavigationProperty.Association.Mapping;

            associationMapping.OnIsCompletelyMappedChanged();
            if (NavigationProperty.Cardinality == Cardinality.ZeroToOne && !(associationMapping.MappingInit || associationMapping.ConditionsMapping.Any(ccm => ccm.Column == column && ccm.Operator == ConditionOperator.IsNotNull)))
            {
                associationMapping.ConditionsMapping.Add(new ColumnConditionMapping {
                    Column = column, Operator = ConditionOperator.IsNotNull
                });
            }
        }
示例#6
0
        public void ChangeMapping(ScalarProperty property, SSDL.Property.Property column)
        {
            if (property == null || column == null)
            {
                throw new ArgumentNullException();
            }

            Dictionary <SSDL.EntityType.EntityType, SSDL.Property.Property> propertyMapping;

            if (!(Mapping.ContainsKey(property) && (propertyMapping = Mapping[property]).ContainsKey(column.EntityType)))
            {
                throw new InvalidOperationException();
            }
            propertyMapping[column.EntityType] = column;
            EntityType.Mapping.OnPropertyChanged("IsCompletlyMapped");
        }
示例#7
0
        public void ChangeMapping(ScalarProperty property, SSDL.Property.Property column)
        {
            if (property == null || column == null)
            {
                throw new ArgumentNullException();
            }

            if (!Mapping.ContainsKey(property))
            {
                throw new InvalidOperationException();
            }
            var oldColumn = Mapping[property];

            Mapping[property] = column;
            OnChanged(property, oldColumn, column);
            MappingAdded(column);
        }
示例#8
0
        public void AddMapping(ScalarProperty property, SSDL.Property.Property column)
        {
            if (property == null || column == null)
            {
                throw new ArgumentNullException();
            }

            if (Mapping.ContainsKey(property))
            {
                var oldColumn = Mapping[property];
                Mapping[property] = column;
                OnChanged(property, oldColumn, column);
            }
            else
            {
                Mapping.Add(property, column);
                OnAdded(property, column);
            }

            MappingAdded(column);
        }
        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);
        }