Ejemplo n.º 1
0
        /// <summary>
        /// Creates the reference value for the given eneity value
        /// </summary>
        /// <param name="entityValue">the entity value</param>
        /// <returns>the reference value</returns>
        public QueryReferenceValue CreateReferenceValue(QueryStructuralValue entityValue)
        {
            ExceptionUtilities.Assert(entityValue.Type is QueryEntityType, "Create reference value needs a value of query entity type, not {0}.", entityValue.Type);

            var referenceValue = new QueryReferenceValue(this, null, this.EvaluationStrategy);

            referenceValue.SetReferenceValue(entityValue);
            return(referenceValue);
        }
Ejemplo n.º 2
0
 public QueryScalarValue EqualTo(QueryStructuralValue otherValue)
 {
     if ((this.IsNull && otherValue.IsNull) || object.ReferenceEquals(this, otherValue))
     {
         return(new QueryScalarValue(EvaluationStrategy.BooleanType, true, this.EvaluationError, this.EvaluationStrategy));
     }
     else
     {
         return(new QueryScalarValue(EvaluationStrategy.BooleanType, false, this.EvaluationError, this.EvaluationStrategy));
     }
 }
Ejemplo n.º 3
0
        private QueryStructuralValue CreateGroupingValue(QueryValue key, QueryCollectionValue elements)
        {
            QueryGroupingType groupingType = new QueryGroupingType(key.Type, elements.Type.ElementType, key.Type.EvaluationStrategy);

            var error  = QueryError.GetErrorFromValues(elements.Elements.Concat(new[] { key }));
            var result = new QueryStructuralValue(groupingType, false, error, groupingType.EvaluationStrategy);

            result.SetValue("Key", key);
            result.SetValue("Elements", elements);

            return(result);
        }
Ejemplo n.º 4
0
        internal void SetReferenceValue(QueryStructuralValue entityValue)
        {
            ExceptionUtilities.CheckArgumentNotNull(entityValue, "entityValue");
            this.EntityValue = entityValue;

            // compute key value
            QueryEntityType entityType = this.Type.QueryEntityType;
            var             keyType    = new QueryRecordType(this.EvaluationStrategy);

            keyType.AddProperties(entityType.Properties.Where(m => m.IsPrimaryKey));

            this.KeyValue = keyType.CreateNewInstance();

            for (int i = 0; i < keyType.Properties.Count; i++)
            {
                this.KeyValue.SetMemberValue(i, entityValue.GetValue(keyType.Properties[i].Name));
            }

            var set = entityType.EntitySet;

            this.EntitySetFullName = set.Container.Name + "." + set.Name;
        }
Ejemplo n.º 5
0
        private bool StructuralValuesAreEqual(QueryStructuralValue firstValueStructural, QueryStructuralValue secondValueStructural)
        {
            if (!this.StructuralTypesAreEqual(firstValueStructural.Type, secondValueStructural.Type))
            {
                return(false);
            }

            if (firstValueStructural.IsNull)
            {
                return(secondValueStructural.IsNull);
            }
            else if (secondValueStructural.IsNull)
            {
                return(false);
            }

            IEnumerable <QueryProperty> membersToCompare = firstValueStructural.Type.Properties;

            if (firstValueStructural.Type is QueryEntityType)
            {
                membersToCompare = membersToCompare.Where(m => m.IsPrimaryKey);
            }

            foreach (QueryProperty member in membersToCompare)
            {
                QueryValue innerFirstvalue  = firstValueStructural.GetValue(member.Name);
                QueryValue innerSecondvalue = secondValueStructural.GetValue(member.Name);

                if (!this.ValuesAreEqual(innerFirstvalue, innerSecondvalue))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Gets a <see cref="QueryStructuralValue"/> value indicating whether two values are not equal.
        /// </summary>
        /// <param name="otherValue">The second value.</param>
        /// <returns>
        /// Instance of <see cref="QueryScalarValue"/> which represents the result of comparison.
        /// </returns>
        public QueryScalarValue NotEqualTo(QueryStructuralValue otherValue)
        {
            bool areEqual = (bool)this.EqualTo(otherValue).Value;

            return(new QueryScalarValue(EvaluationStrategy.BooleanType, !areEqual, this.EvaluationError, this.EvaluationStrategy));
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Compares a NamedValue to a QueryStructuralValue
 /// </summary>
 /// <param name="comparer">Comparer used to see if the specified values are equal</param>
 /// <param name="existing">Existing QueryStructualValue to compare to</param>
 /// <param name="namedValue">NamedValue to compare against</param>
 /// <param name="scalarComparer">Scalar comparer to use</param>
 public static void CompareStructuralValue(this IQueryStructuralValueToNamedValueComparer comparer, QueryStructuralValue existing, NamedValue namedValue, IQueryScalarValueToClrValueComparer scalarComparer)
 {
     comparer.Compare(existing, (new NamedValue[] { namedValue }).AsEnumerable(), scalarComparer);
 }