예제 #1
0
 public void AddColumnCondition(StorageConditionPropertyMapping storageConditionPropertyMapping)
 {
     if (SingleFragment != null)
     {
         SingleFragment.AddConditionProperty(storageConditionPropertyMapping);
     }
 }
예제 #2
0
        public void Can_get_and_set_IsNull()
        {
            var conditionPropertyMapping
                = new StorageConditionPropertyMapping(null, new EdmProperty("C"), null, false);

            Assert.Null(conditionPropertyMapping.Value);
            Assert.False((bool)conditionPropertyMapping.IsNull);
        }
예제 #3
0
        public void Can_get_and_set_Value()
        {
            var conditionPropertyMapping
                = new StorageConditionPropertyMapping(null, new EdmProperty("C"), 42, null);

            Assert.Equal(42, conditionPropertyMapping.Value);
            Assert.Null(conditionPropertyMapping.IsNull);
        }
예제 #4
0
        public void RemoveConditionProperty(StorageConditionPropertyMapping condition)
        {
            DebugCheck.NotNull(condition);

            var conditionMember = condition.EdmProperty ?? condition.ColumnProperty;

            m_conditionProperties.Remove(conditionMember);
        }
        public void Can_get_and_set_IsNull()
        {
            var conditionPropertyMapping
                = new StorageConditionPropertyMapping(null, new EdmProperty("C"), null, false);

            Assert.Null(conditionPropertyMapping.Value);
            Assert.False((bool)conditionPropertyMapping.IsNull);
        }
 public void Can_get_and_set_Value()
 {
     var conditionPropertyMapping
         = new StorageConditionPropertyMapping(null, new EdmProperty("C"), 42, null);
     
     Assert.Equal(42, conditionPropertyMapping.Value);
     Assert.Null(conditionPropertyMapping.IsNull);
 }
예제 #7
0
        private static DbExpression GeneratePredicate(StorageConditionPropertyMapping condition, DbExpression row)
        {
            Debug.Assert(condition.EdmProperty == null, "C-side conditions are not supported in function mappings.");
            var columnRef = GenerateColumnRef(row, condition.ColumnProperty);

            if (condition.IsNull.HasValue)
            {
                return(condition.IsNull.Value ? columnRef.IsNull() : (DbExpression)columnRef.IsNull().Not());
            }
            else
            {
                return(columnRef.Equal(columnRef.ResultType.Constant(condition.Value)));
            }
        }
예제 #8
0
        public void Can_get_and_set_column_property()
        {
            var columnMember1 = new EdmProperty("C");
            var conditionPropertyMapping
                = new StorageConditionPropertyMapping(null, columnMember1, 42, null);

            Assert.Same(columnMember1, conditionPropertyMapping.ColumnProperty);

            var columnMember2 = new EdmProperty("C");

            conditionPropertyMapping.ColumnProperty = columnMember2;

            Assert.Same(columnMember2, conditionPropertyMapping.ColumnProperty);
        }
        public void Can_get_and_set_column_property()
        {
            var columnMember1 = new EdmProperty("C");
            var conditionPropertyMapping
                = new StorageConditionPropertyMapping(null, columnMember1, 42, null);

            Assert.Same(columnMember1, conditionPropertyMapping.ColumnProperty);

            var columnMember2 = new EdmProperty("C");

            conditionPropertyMapping.ColumnProperty = columnMember2;

            Assert.Same(columnMember2, conditionPropertyMapping.ColumnProperty);
        }
예제 #10
0
        public static void GetIdentity_of_StorageConditionPropertyMapping_returns_expected_value()
        {
            var typeUsage = TypeUsage.Create(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));
            var property1 = new EdmProperty("A", typeUsage);
            var property2 = new EdmProperty("B", typeUsage);

            StoragePropertyMapping mapping = new StorageConditionPropertyMapping(property1, null, "V", null);

            Assert.Equal("ConditionProperty(Identity=A)",
                         BaseMetadataMappingVisitor.IdentityHelper.GetIdentity(mapping));

            mapping = new StorageConditionPropertyMapping(null, property2, "V", null);

            Assert.Equal("ConditionProperty(ColumnIdentity=B)",
                         BaseMetadataMappingVisitor.IdentityHelper.GetIdentity(mapping));
        }
        public void Can_add_column_conditions()
        {
            var entitySet1     = new EntitySet();
            var associationSet = new AssociationSet("AS", new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace));

            var associationSetMapping
                = new StorageAssociationSetMapping(associationSet, entitySet1);

            Assert.Empty(associationSetMapping.ColumnConditions);

            var conditionPropertyMapping
                = new StorageConditionPropertyMapping(null, new EdmProperty("C"), 42, null);

            associationSetMapping.AddColumnCondition(conditionPropertyMapping);

            Assert.Same(conditionPropertyMapping, associationSetMapping.ColumnConditions.Single());
        }
예제 #12
0
        /// <summary>
        ///     Add a condition property mapping as a child of this complex property mapping
        ///     Condition Property Mapping specifies a Condition either on the C side property or S side property.
        /// </summary>
        /// <param name="conditionPropertyMap"> The mapping that needs to be added </param>
        internal void AddConditionProperty(
            StorageConditionPropertyMapping conditionPropertyMap, Action <EdmMember> duplicateMemberConditionError)
        {
            //Same Member can not have more than one Condition with in the
            //same Mapping Fragment.
            var conditionMember = conditionPropertyMap.EdmProperty ?? conditionPropertyMap.ColumnProperty;

            Debug.Assert(conditionMember != null);

            if (!m_conditionProperties.ContainsKey(conditionMember))
            {
                m_conditionProperties.Add(conditionMember, conditionPropertyMap);
            }
            else
            {
                duplicateMemberConditionError(conditionMember);
            }
        }
예제 #13
0
        protected override void Visit(StorageConditionPropertyMapping storageConditionPropertyMapping)
        {
            int index;

            if (!AddObjectToSeenListAndHashBuilder(storageConditionPropertyMapping, out index))
            {
                return;
            }

            AddObjectStartDumpToHashBuilder(storageConditionPropertyMapping, index);

            #region Inner data visit

            AddObjectContentToHashBuilder(storageConditionPropertyMapping.IsNull);
            AddObjectContentToHashBuilder(storageConditionPropertyMapping.Value);

            base.Visit(storageConditionPropertyMapping);

            #endregion

            AddObjectEndDumpToHashBuilder();
        }
        public void Can_add_and_remove_column_conditions()
        {
            var mappingFragment
                = new StorageMappingFragment(
                      new EntitySet(),
                      new StorageEntityTypeMapping(
                          new StorageEntitySetMapping(
                              new EntitySet(),
                              new StorageEntityContainerMapping(new EntityContainer()))), false);

            Assert.Empty(mappingFragment.ColumnConditions);

            var conditionPropertyMapping
                = new StorageConditionPropertyMapping(null, new EdmProperty("C"), 42, null);

            mappingFragment.AddConditionProperty(conditionPropertyMapping);

            Assert.Same(conditionPropertyMapping, mappingFragment.ColumnConditions.Single());

            mappingFragment.RemoveConditionProperty(conditionPropertyMapping);

            Assert.Empty(mappingFragment.ColumnConditions);
        }
 protected virtual void Visit(StorageConditionPropertyMapping storageConditionPropertyMapping)
 {
     Visit(storageConditionPropertyMapping.ColumnProperty);
     Visit(storageConditionPropertyMapping.EdmProperty);
 }
 protected virtual void Visit(StorageConditionPropertyMapping storageConditionPropertyMapping)
 {
     Visit(storageConditionPropertyMapping.ColumnProperty);
     Visit(storageConditionPropertyMapping.EdmProperty);
 }
        public void Can_add_and_remove_column_conditions()
        {
            var mappingFragment
                = new StorageMappingFragment(
                    new EntitySet(),
                    new StorageEntityTypeMapping(
                        new StorageEntitySetMapping(
                            new EntitySet(),
                            new StorageEntityContainerMapping(new EntityContainer("C", DataSpace.CSpace)))), false);

            Assert.Empty(mappingFragment.ColumnConditions);

            var conditionPropertyMapping
                = new StorageConditionPropertyMapping(null, new EdmProperty("C"), 42, null);

            mappingFragment.AddConditionProperty(conditionPropertyMapping);

            Assert.Same(conditionPropertyMapping, mappingFragment.ColumnConditions.Single());

            mappingFragment.RemoveConditionProperty(conditionPropertyMapping);

            Assert.Empty(mappingFragment.ColumnConditions);
        }
        /// <summary>
        ///     Add a condition property mapping as a child of this complex property mapping
        ///     Condition Property Mapping specifies a Condition either on the C side property or S side property.
        /// </summary>
        /// <param name="conditionPropertyMap"> The mapping that needs to be added </param>
        internal void AddConditionProperty(
            StorageConditionPropertyMapping conditionPropertyMap, Action<EdmMember> duplicateMemberConditionError)
        {
            //Same Member can not have more than one Condition with in the 
            //same Mapping Fragment.
            var conditionMember = conditionPropertyMap.EdmProperty ?? conditionPropertyMap.ColumnProperty;

            Debug.Assert(conditionMember != null);

            if (!m_conditionProperties.ContainsKey(conditionMember))
            {
                m_conditionProperties.Add(conditionMember, conditionPropertyMap);
            }
            else
            {
                duplicateMemberConditionError(conditionMember);
            }
        }
 public void AddColumnCondition(StorageConditionPropertyMapping storageConditionPropertyMapping)
 {
     if (SingleFragment != null)
     {
         SingleFragment.AddConditionProperty(storageConditionPropertyMapping);
     }
 }
        internal void RemoveConditionProperty(StorageConditionPropertyMapping condition)
        {
            DebugCheck.NotNull(condition);

            var conditionMember = condition.EdmProperty ?? condition.ColumnProperty;

            m_conditionProperties.Remove(conditionMember);
        }
        internal void AddConditionProperty(StorageConditionPropertyMapping conditionPropertyMap)
        {
            DebugCheck.NotNull(conditionPropertyMap);

            AddConditionProperty(conditionPropertyMap, _ => { });
        }
예제 #22
0
        internal void AddConditionProperty(StorageConditionPropertyMapping conditionPropertyMap)
        {
            DebugCheck.NotNull(conditionPropertyMap);

            AddConditionProperty(conditionPropertyMap, _ => { });
        }
 public static string GetIdentity(StorageConditionPropertyMapping mapping)
 {
     return(mapping.EdmProperty != null
         ? "ConditionProperty(Identity=" + mapping.EdmProperty.Identity + ")"
         : "ConditionProperty(ColumnIdentity=" + mapping.ColumnProperty.Identity + ")");
 }
        private static DbExpression GeneratePredicate(StorageConditionPropertyMapping condition, DbExpression row)
        {
            Debug.Assert(condition.EdmProperty == null, "C-side conditions are not supported in function mappings.");
            var columnRef = GenerateColumnRef(row, condition.ColumnProperty);

            if (condition.IsNull.HasValue)
            {
                return condition.IsNull.Value ? columnRef.IsNull() : (DbExpression)columnRef.IsNull().Not();
            }
            else
            {
                return columnRef.Equal(columnRef.ResultType.Constant(condition.Value));
            }
        }
        private void WriteConditionElement(StorageConditionPropertyMapping condition)
        {
            DebugCheck.NotNull(condition);

            _xmlWriter.WriteStartElement(StorageMslConstructs.ConditionElement);
            if (condition.IsNull.HasValue)
            {
                _xmlWriter.WriteAttributeString(
                    StorageMslConstructs.ConditionIsNullAttribute, GetLowerCaseStringFromBoolValue(condition.IsNull.Value));
            }
            else
            {
                if (condition.Value is bool)
                {
                    _xmlWriter.WriteAttributeString(StorageMslConstructs.ConditionValueAttribute, (bool)condition.Value ? "1" : "0");
                }
                else
                {
                    _xmlWriter.WriteAttributeString(StorageMslConstructs.ConditionValueAttribute, condition.Value.ToString());
                }
            }
            _xmlWriter.WriteAttributeString(StorageMslConstructs.ConditionColumnNameAttribute, condition.ColumnProperty.Name);
            _xmlWriter.WriteEndElement();
        }
        public void Can_add_column_conditions()
        {
            var entitySet1 = new EntitySet();
            var associationSet = new AssociationSet("AS", new AssociationType());

            var associationSetMapping
                = new StorageAssociationSetMapping(associationSet, entitySet1);

            Assert.Empty(associationSetMapping.ColumnConditions);

            var conditionPropertyMapping
                = new StorageConditionPropertyMapping(null, new EdmProperty("C"), 42, null);

            associationSetMapping.AddColumnCondition(conditionPropertyMapping);

            Assert.Same(conditionPropertyMapping, associationSetMapping.ColumnConditions.Single());
        }
        public static void GetIdentity_of_StorageConditionPropertyMapping_returns_expected_value()
        {
            var typeUsage = TypeUsage.Create(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));
            var property1 = new EdmProperty("A", typeUsage);
            var property2 = new EdmProperty("B", typeUsage);

            StoragePropertyMapping mapping = new StorageConditionPropertyMapping(property1, null, "V", null);

            Assert.Equal("ConditionProperty(Identity=A)",
                BaseMetadataMappingVisitor.IdentityHelper.GetIdentity(mapping));

            mapping = new StorageConditionPropertyMapping(null, property2, "V", null);

            Assert.Equal("ConditionProperty(ColumnIdentity=B)",
                BaseMetadataMappingVisitor.IdentityHelper.GetIdentity(mapping));
        }
        protected override void Visit(StorageConditionPropertyMapping storageConditionPropertyMapping)
        {
            int index;
            if (!AddObjectToSeenListAndHashBuilder(storageConditionPropertyMapping, out index))
            {
                return;
            }

            AddObjectStartDumpToHashBuilder(storageConditionPropertyMapping, index);

            #region Inner data visit

            AddObjectContentToHashBuilder(storageConditionPropertyMapping.IsNull);
            AddObjectContentToHashBuilder(storageConditionPropertyMapping.Value);

            base.Visit(storageConditionPropertyMapping);

            #endregion

            AddObjectEndDumpToHashBuilder();
        }