Ejemplo n.º 1
0
        // Constructors

        public BatchingCommandProcessor(CommandFactory factory, int batchSize, int maxQueryParameterCount)
            : base(factory, maxQueryParameterCount)
        {
            ArgumentValidator.EnsureArgumentIsGreaterThan(batchSize, 1, nameof(batchSize));
            this.batchSize = batchSize;
            tasks          = new Queue <SqlTask>();
        }
Ejemplo n.º 2
0
        // Constructors

        public BatchingCommandProcessor(CommandFactory factory, int batchSize)
            : base(factory)
        {
            ArgumentValidator.EnsureArgumentIsGreaterThan(batchSize, 1, "batchSize");
            this.batchSize = batchSize;
            tasks          = new Queue <SqlTask>();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes new instance of this type.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="typeName">Name of the type.</param>
 /// <param name="length">The length.</param>
 /// <param name="precision">The precision.</param>
 /// <param name="scale">The scale.</param>
 public SqlValueType(SqlType type, string typeName, int?length, int?precision, int?scale)
 {
     if ((type == SqlType.Unknown) != (typeName != null))
     {
         throw new ArgumentException(Strings.ExInvalidArgumentsNonNullTypeNameIsAllowedIfAndOnlyIfTypeEqualsSqlTypeUnknown);
     }
     if (precision.HasValue && precision != 0 && length.HasValue && length != 0)
     {
         throw new ArgumentException(Strings.ExInvalidArgumentsPrecisionAndLengthShouldNotBeUsedTogether);
     }
     if (precision.HasValue != scale.HasValue)
     {
         throw new ArgumentException(Strings.ExInvalidArgumentsScaleAndPrecisionShouldBeUsedTogether);
     }
     if (typeName != null)
     {
         ArgumentValidator.EnsureArgumentNotNullOrEmpty(typeName, "typeName");
     }
     if (length != null)
     {
         ArgumentValidator.EnsureArgumentIsGreaterThan(length.Value, 0, "length");
     }
     if (precision != null)
     {
         ArgumentValidator.EnsureArgumentIsInRange(scale.Value, 0, precision.Value, "scale");
     }
     Type      = type;
     TypeName  = typeName;
     Length    = length;
     Precision = precision;
     Scale     = scale;
 }
        // Constructors

        public PersistParameterBinding(TypeMapping typeMapping, int fieldIndex, ParameterTransmissionType transmissionType, PersistParameterBindingType bindingType)
            : base(typeMapping, transmissionType)
        {
            ArgumentValidator.EnsureArgumentIsGreaterThan(fieldIndex, -1, "fieldIndex");
            ArgumentValidator.EnsureArgumentNotNull(typeMapping, "typeMapping");

            FieldIndex  = fieldIndex;
            BindingType = bindingType;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Performs full-text query for the specified search condition.
        /// </summary>
        /// <typeparam name="T">Type of the entity to query full-text index of.</typeparam>
        /// <param name="searchCriteria">Search condition.</param>
        /// <param name="topNByRank">
        /// Specifies how many highest ranked matches (in descending order) result set should be returned.
        /// Result set may contain less number of items than specified by the parameter.
        /// </param>
        /// <returns>
        /// An <see cref="IQueryable{T}"/> of <see cref="FullTextMatch{T}"/>
        /// allowing to continue building the query.
        /// </returns>
        public IQueryable <FullTextMatch <T> > ContainsTable <T>([NotNull] Expression <Func <ConditionEndpoint, IOperand> > searchCriteria, int topNByRank)
            where T : Entity
        {
            ArgumentValidator.EnsureArgumentNotNull(searchCriteria, "searchCriteria");
            ArgumentValidator.EnsureArgumentIsGreaterThan(topNByRank, 0, "topNByRank");
            var method     = WellKnownMembers.Query.ContainsTableExprTopNByRank.MakeGenericMethod(typeof(T));
            var expression = Expression.Call(null, method, searchCriteria, Expression.Constant(topNByRank));

            return(Provider.CreateQuery <FullTextMatch <T> >(expression));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Performs full-text query for the text specified in free text form.
        /// Limits the result by top number of elements, sorted by rank in descending order.
        /// </summary>
        /// <typeparam name="T">Type of the entity to query full-text index of.</typeparam>
        /// <param name="searchCriteria">The search criteria in free text form.</param>
        /// <param name="topNByRank">Top number of elements to be returned.</param>
        /// <returns>
        /// An <see cref="IQueryable{T}"/> of <see cref="FullTextMatch{T}"/>
        /// allowing to continue building the query.
        /// </returns>
        public IQueryable <FullTextMatch <T> > FreeText <T>(Expression <Func <string> > searchCriteria, int topNByRank)
            where T : Entity
        {
            ArgumentValidator.EnsureArgumentNotNull(searchCriteria, "searchCriteria");
            ArgumentValidator.EnsureArgumentIsGreaterThan(topNByRank, 0, "topNByRank");
            var method     = WellKnownMembers.Query.FreeTextExpressionTopNByRank.MakeGenericMethod(typeof(T));
            var expression = Expression.Call(null, method, searchCriteria, Expression.Constant(topNByRank));

            return(Provider.CreateQuery <FullTextMatch <T> >(expression));
        }
Ejemplo n.º 7
0
        public void CombinedTest()
        {
            ArgumentValidator.EnsureArgumentIsGreaterThan(1, 0, "x");
            AssertEx.ThrowsArgumentOutOfRangeException(() => ArgumentValidator.EnsureArgumentIsGreaterThan(0, 0, "x"));
            AssertEx.ThrowsArgumentOutOfRangeException(() => ArgumentValidator.EnsureArgumentIsGreaterThan(-1, 0, "x"));

            ArgumentValidator.EnsureArgumentIsLessThan(-1, 0, "x");
            AssertEx.ThrowsArgumentOutOfRangeException(() => ArgumentValidator.EnsureArgumentIsLessThan(0, 0, "x"));
            AssertEx.ThrowsArgumentOutOfRangeException(() => ArgumentValidator.EnsureArgumentIsLessThan(1, 0, "x"));
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Creates a stream <see cref="DataTypeInfo"/>.
 /// </summary>
 public static DataTypeInfo Stream(
     SqlType sqlType,
     DataTypeFeatures features,
     int maxLength,
     params string[] nativeTypes)
 {
     ArgumentValidator.EnsureArgumentIsGreaterThan(maxLength, 0, "maxLength");
     return(new DataTypeInfo
     {
         Type = sqlType,
         Features = features,
         MaxLength = maxLength,
         NativeTypes = nativeTypes.ToArraySafely(),
     });
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Creates a fractional <see cref="DataTypeInfo"/>.
 /// </summary>
 public static DataTypeInfo Fractional(
     SqlType sqlType,
     DataTypeFeatures features,
     ValueRange valueRange,
     int maxPrecision,
     params string[] nativeTypes)
 {
     ArgumentValidator.EnsureArgumentNotNull(valueRange, "valueRange");
     ArgumentValidator.EnsureArgumentIsGreaterThan(maxPrecision, 0, "maxPrecision");
     return(new DataTypeInfo
     {
         Type = sqlType,
         Features = features,
         ValueRange = valueRange,
         MaxPrecision = maxPrecision,
         NativeTypes = nativeTypes.ToArraySafely(),
     });
 }
 /// <summary>
 /// Initializes a new instance of this class.
 /// </summary>
 /// <param name="field">The field whose value will be fetched.</param>
 /// <param name="entitySetItemCountLimit">The maximal count of items
 /// which will be loaded during prefetch of an <see cref="EntitySet{TItem}"/>.</param>
 /// <param name="fetchFieldsOfReferencedEntity">If it is set to <see langword="true"/>
 /// then fields' values of an <see cref="Entity"/> referenced by <see cref="Field"/>
 /// will be fetched.</param>
 /// <param name="fetchLazyFields">if set to <see langword="true"/>
 /// children lazy-load fields will be fetched.</param>
 /// <param name="keyExtractionSubscriber">The delegate which will be invoked
 /// if a key of a referenced entity has been extracted and
 /// its exact type can't be get or inferred.</param>
 public PrefetchFieldDescriptor(
     FieldInfo field,
     int?entitySetItemCountLimit,
     bool fetchFieldsOfReferencedEntity,
     bool fetchLazyFields,
     Action <Key, FieldInfo, Key> keyExtractionSubscriber)
 {
     ArgumentValidator.EnsureArgumentNotNull(field, "field");
     if (entitySetItemCountLimit != null)
     {
         ArgumentValidator.EnsureArgumentIsGreaterThan(entitySetItemCountLimit.Value, 0,
                                                       "entitySetItemCountLimit");
     }
     Field = field;
     FetchFieldsOfReferencedEntity = fetchFieldsOfReferencedEntity;
     EntitySetItemCountLimit       = entitySetItemCountLimit;
     FetchLazyFields = fetchLazyFields;
     this.keyExtractionSubscriber = keyExtractionSubscriber;
 }
        // Constructors

        public EntityGroupTask(TypeInfo type, int[] columnIndexes, PrefetchManager manager)
        {
            ArgumentValidator.EnsureArgumentNotNull(type, "type");
            ArgumentValidator.EnsureArgumentNotNull(columnIndexes, "columnIndexes");
            ArgumentValidator.EnsureArgumentIsGreaterThan(columnIndexes.Length, 0, "columnIndexes.Length");
            ArgumentValidator.EnsureArgumentNotNull(manager, "processor");

            this.type          = type;
            this.columnIndexes = columnIndexes;
            this.manager       = manager;
            var cachedHashCode = 0;

            for (var i = 0; i < columnIndexes.Length; i++)
            {
                cachedHashCode = unchecked (379 * cachedHashCode + columnIndexes[i]);
            }
            cachedHashCode = unchecked (cachedHashCode ^ type.GetHashCode());
            cacheKey       = new CacheKey(columnIndexes, type, cachedHashCode);
        }
Ejemplo n.º 12
0
        // Constructors

        public EntityGroupTask(TypeInfo type, int[] columnIndexes, PrefetchManager manager)
        {
            ArgumentValidator.EnsureArgumentNotNull(type, nameof(type));
            ArgumentValidator.EnsureArgumentNotNull(columnIndexes, nameof(columnIndexes));
            ArgumentValidator.EnsureArgumentIsGreaterThan(columnIndexes.Length, 0, "columnIndexes.Length");
            ArgumentValidator.EnsureArgumentNotNull(manager, nameof(manager));

            this.type    = type;
            this.manager = manager;
            var cachedHashCode = 0;

            foreach (var columnIndex in columnIndexes)
            {
                cachedHashCode = unchecked (379 * cachedHashCode + columnIndex);
            }

            cachedHashCode ^= type.GetHashCode();
            cacheKey        = new CacheKey(columnIndexes, type, cachedHashCode);
        }
 private static void AddConverter <T>(params Type[] types)
 {
     ArgumentValidator.EnsureArgumentIsGreaterThan(types.Length, -1, "types.Length");
     supportedConversions.Add(typeof(T), new List <Type>(types));
 }