示例#1
0
        private void AddSourceModel(Model model)
        {
            Debug.Assert(!_sourceModels.Contains(model));

            _sourceModels = _sourceModels.Add(model);
            if (_autoColumnSelector == null)
            {
                _autoColumnSelector = model.Columns;
            }
            else
            {
                _autoColumnSelector = _autoColumnSelector.Merge(model.Columns);
            }
        }
示例#2
0
        /// <summary>Ensures set contain only elements that are present either in the current set or in the specified collection, but not both.</summary>
        /// <param name="source">The current set.</param>
        /// <param name="other">The collection to compare to the current set.</param>
        /// <returns>A new set if there is any modification to current sealed set; otherwise, the current set.</returns>
        public static IModels SymmetricExcept(this IModels source, IModels other)
        {
            source.VerifyNotNull(nameof(source));
            other.VerifyNotNull(nameof(other));

            IModels removedModelSet = Models.Empty;

            foreach (var item in source)
            {
                if (other.Contains(item))
                {
                    removedModelSet = removedModelSet.Add(item);
                    source          = source.Remove(item);
                }
            }

            foreach (var item in other)
            {
                if (removedModelSet.Contains(item))
                {
                    source = source.Add(item);
                }
            }

            return(source);
        }
示例#3
0
 private static void VerifyAggregateSourceModels(Column sourceColumn, string exceptionParamName, IModels modelSet)
 {
     foreach (var model in sourceColumn.AggregateSourceModels)
     {
         if (!modelSet.Contains(model))
         {
             throw new ArgumentException(DiagnosticMessages.DbQueryBuilder_InvalidAggregateSourceModel(model), exceptionParamName);
         }
     }
 }
示例#4
0
 /// <summary>
 /// Determines whether source model set contains any of the specified model set.
 /// </summary>
 /// <param name="source">The source model set.</param>
 /// <param name="other">The specified model set.</param>
 /// <returns><see langword="true" /> if source model set contains any of the specified model set, otherwise <see langword="false"/>.</returns>
 public static bool ContainsAny(this IModels source, IModels other)
 {
     foreach (var item in other)
     {
         if (source.Contains(item))
         {
             return(true);
         }
     }
     return(false);
 }
示例#5
0
 private static bool ContainsAll(this IModels source, IModels other)
 {
     foreach (var item in other)
     {
         if (!source.Contains(item))
         {
             return(false);
         }
     }
     return(true);
 }
示例#6
0
        /// <summary>Determines whether the current set overlaps with the specified collection.</summary>
        /// <param name="source">The current set.</param>
        /// <param name="other">The collection to compare to the current set.</param>
        /// <returns><see langword="true"/> if the current set overlaps with the specified collection; otherwise, <see langword="false" />.</returns>
        public static bool Overlaps(this IModels source, IModels other)
        {
            source.VerifyNotNull(nameof(source));
            other.VerifyNotNull(nameof(other));

            foreach (var item in source)
            {
                if (other.Contains(item))
                {
                    return(true);
                }
            }
            return(false);
        }
示例#7
0
        /// <summary>Removes the models to ensure the set contains only models both exist in this set and the specified collection.</summary>
        /// <param name="source">The current set.</param>
        /// <param name="other">The collection to compare to the current set.</param>
        /// <returns>A new set if there is any modification to current set and current set sealed; otherwise, the current set.</returns>
        public static IModels Intersect(this IModels source, IModels other)
        {
            source.VerifyNotNull(nameof(source));
            other.VerifyNotNull(nameof(other));

            foreach (var item in source)
            {
                if (!other.Contains(item))
                {
                    source = source.Remove(item);
                }
            }
            return(source);
        }
示例#8
0
        private void VerifyScalarSourceModels(IModels containsBy, Column sourceColumn, string exceptionParamName)
        {
            if (sourceColumn.ScalarSourceModels.Count == 0 && sourceColumn.GetExpression() == null)
            {
                throw new ArgumentException(DiagnosticMessages.Column_EmptyScalarSourceModels, exceptionParamName);
            }

            foreach (var model in sourceColumn.ScalarSourceModels)
            {
                if (!containsBy.Contains(model))
                {
                    throw new ArgumentException(DiagnosticMessages.DbQueryBuilder_InvalidScalarSourceModel(model), exceptionParamName);
                }
            }
        }