/// <summary>
        /// Create a facet query parameter
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="aliasName">Name of alias added in query</param>
        /// <param name="query">Query used to make facet</param>
        /// <param name="instance">Instance of facet ready to configure</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> FacetQuery <TDocument>(this DocumentSearch <TDocument> documentSearch, string aliasName, Action <SearchQuery <TDocument> > query, Action <IFacetQueryParameter <TDocument> > instance = null)
            where TDocument : Document
        {
            Checker.IsNull(query);

            var parameter = documentSearch.ServiceProvider.GetService <IFacetQueryParameter <TDocument> >();

            parameter.AliasName(aliasName);
            var search = documentSearch.ServiceProvider.GetService <SearchQuery <TDocument> >();

            query.Invoke(search);
            parameter.Query(search);

            instance?.Invoke(parameter);

            documentSearch.Add(parameter);

            // ReSharper disable once InvertIf
            if (!documentSearch.Contains <IFacetsResult <TDocument> >())
            {
                var facetsResult = documentSearch.ServiceProvider.GetService <IFacetsResult <TDocument> >();
                documentSearch.Add(facetsResult);
            }

            return(documentSearch);
        }
        /// <summary>
        /// Create a limit and a offset parameters
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="itemsPerPage">Quantity of items in one page</param>
        /// <param name="currentPage">Current page</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> Page <TDocument>(this DocumentSearch <TDocument> documentSearch, long itemsPerPage, long currentPage)
            where TDocument : Document
        {
            documentSearch.Limit(itemsPerPage);
            documentSearch.Offset((currentPage - 1) * itemsPerPage);

            return(documentSearch);
        }
        /// <summary>
        /// Initiates the asynchronous execution to get all the remaining results from DynamoDB.
        /// </summary>
        /// <param name="cancellationToken">Token which can be used to cancel the task.</param>
        /// <returns>
        /// A Task that can be used to poll or wait for results, or both.
        /// Results will include the remaining result items from DynamoDB.
        /// </returns>
        public async Task <List <T> > GetRemainingAsync(CancellationToken cancellationToken = default(CancellationToken))
        {
            var documents = await DocumentSearch.GetRemainingHelperAsync(cancellationToken).ConfigureAwait(false);

            List <T> items = SourceContext.FromDocumentsHelper <T>(documents, this.Config).ToList();

            return(items);
        }
 /// <summary>
 /// Initiates the asynchronous execution to get all the remaining results from DynamoDB.
 /// </summary>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 ///
 /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetRemaining
 ///         operation.</returns>
 public IAsyncResult BeginGetRemaining(AsyncCallback callback, object state)
 {
     return(DynamoDBAsyncExecutor.BeginOperation(() =>
     {
         var documents = DocumentSearch.GetRemainingHelper(true);
         List <T> items = SourceContext.FromDocumentsHelper <T>(documents, Config).ToList();
         return items;
     }, callback, state));
 }
 /// <summary>
 /// Initiates the asynchronous execution to get all the remaining results from DynamoDB.
 /// </summary>
 /// <param name="cancellationToken">Token which can be used to cancel the task.</param>
 /// <returns>
 /// A Task that can be used to poll or wait for results, or both.
 /// Results will include the remaining result items from DynamoDB.
 /// </returns>
 public Task <List <T> > GetRemainingAsync(CancellationToken cancellationToken = default(CancellationToken))
 {
     return(AsyncRunner.Run(() =>
     {
         var documents = DocumentSearch.GetRemainingHelper(true);
         List <T> items = SourceContext.FromDocuments <T>(documents).ToList();
         return items;
     }, cancellationToken));
 }
Beispiel #6
0
 /// <summary>
 /// Initiates the asynchronous execution to get all the remaining results from DynamoDB.
 /// </summary>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 ///
 /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetRemaining
 ///         operation.</returns>
 public void GetRemainingAsync(AmazonDynamoCallback <List <T> > callback, object state)
 {
     DynamoDBAsyncExecutor.AsyncOperation(() =>
     {
         var documents  = DocumentSearch.GetRemainingHelper(true);
         List <T> items = SourceContext.FromDocumentsHelper <T>(documents, Config).ToList();
         return(items);
     }, "GetRemainingAsync", callback, state);
 }
        /// <summary>
        /// Create a sort parameter configured to do a random sort
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> SortRandomly <TDocument>(this DocumentSearch <TDocument> documentSearch)
            where TDocument : Document
        {
            var parameter = documentSearch.ServiceProvider.GetService <ISortRandomlyParameter <TDocument> >();

            documentSearch.Add(parameter);

            return(documentSearch);
        }
        /// <summary>
        /// Create a fields parameter
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="fieldExpressions">Expressions used to find fields name</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> Fields <TDocument>(this DocumentSearch <TDocument> documentSearch, params Expression <Func <TDocument, object> >[] fieldExpressions)
            where TDocument : Document
        {
            var parameter = documentSearch.ServiceProvider.GetService <IFieldsParameter <TDocument> >();

            parameter.FieldExpressions(fieldExpressions);

            documentSearch.Add(parameter);

            return(documentSearch);
        }
        /// <summary>
        /// Create a facet limit parameter
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="value">Value of limit</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> FacetLimit <TDocument>(this DocumentSearch <TDocument> documentSearch, int value)
            where TDocument : Document
        {
            var parameter = documentSearch.ServiceProvider.GetService <IFacetLimitParameter <TDocument> >();

            parameter.Value(value);

            documentSearch.Add(parameter);

            return(documentSearch);
        }
        /// <summary>
        /// Create a offset parameter
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="value">Value of offset</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> Offset <TDocument>(this DocumentSearch <TDocument> documentSearch, long value)
            where TDocument : Document
        {
            var parameter = documentSearch.ServiceProvider.GetService <IOffsetParameter <TDocument> >();

            parameter.Value(value);

            documentSearch.Add(parameter);

            return(documentSearch);
        }
        /// <summary>
        /// Create a cursor mark parameter
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="value">Mark used to paging through the results</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> CursorMark <TDocument>(this DocumentSearch <TDocument> documentSearch, string value)
            where TDocument : Document
        {
            var parameter = documentSearch.ServiceProvider.GetService <ICursorMarkParameter>();

            parameter.CursorMark(value);

            documentSearch.Add(parameter);

            return(documentSearch);
        }
        /// <summary>
        /// Create a query field parameter
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="expression">Query used to make query field</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> QueryField <TDocument>(this DocumentSearch <TDocument> documentSearch, string expression)
            where TDocument : Document
        {
            var parameter = documentSearch.ServiceProvider.GetService <IQueryFieldParameter <TDocument> >();

            parameter.Expression(expression);

            documentSearch.Add(parameter);

            return(documentSearch);
        }
        /// <summary>
        /// Create a minimum should match
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="value">Expression used to make mm parameter</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> MinimumShouldMatch <TDocument>(this DocumentSearch <TDocument> documentSearch, string value)
            where TDocument : Document
        {
            var parameter = documentSearch.ServiceProvider.GetService <IMinimumShouldMatchParameter <TDocument> >();

            parameter.Value(value);

            documentSearch.Add(parameter);

            return(documentSearch);
        }
        /// <summary>
        /// Create a offset parameter
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="conditional">Conditional to add parameter</param>
        /// <param name="value">Value of offset</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> OffsetIf <TDocument>(this DocumentSearch <TDocument> documentSearch, Func <bool> conditional, long value)
            where TDocument : Document
        {
            Checker.IsNull(conditional);

            if (conditional.Invoke())
            {
                documentSearch.Offset(value);
            }

            return(documentSearch);
        }
        /// <summary>
        /// Create a facet range parameter
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="conditional">Conditional to add parameter</param>
        /// <param name="aliasName">Name of alias added in query</param>
        /// <param name="fieldExpression">Expression used to find field name</param>
        /// <param name="centerPoint">Center point to spatial filter</param>
        /// <param name="distance">Distance from center point</param>
        /// <param name="instance">Instance of parameter ready to configure</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> FacetSpatialIf <TDocument>(this DocumentSearch <TDocument> documentSearch, Func <bool> conditional, string aliasName, Expression <Func <TDocument, object> > fieldExpression, GeoCoordinate centerPoint, decimal distance, Action <IFacetSpatialParameter <TDocument> > instance = null)
            where TDocument : Document
        {
            Checker.IsNull(conditional);

            if (conditional.Invoke())
            {
                documentSearch.FacetSpatial(aliasName, fieldExpression, centerPoint, distance, instance);
            }

            return(documentSearch);
        }
        /// <summary>
        /// Create a minimum should match
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="conditional">Conditional to add parameter</param>
        /// <param name="value">Expression used to make mm parameter</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> MinimumShouldMatchIf <TDocument>(this DocumentSearch <TDocument> documentSearch, Func <bool> conditional, string value)
            where TDocument : Document
        {
            Checker.IsNull(conditional);

            if (conditional.Invoke())
            {
                documentSearch.MinimumShouldMatch(value);
            }

            return(documentSearch);
        }
        /// <summary>
        /// Create a filter parameter in commom case (field equals value, field with value in collection)
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="conditional">Conditional to add parameter</param>
        /// <param name="fieldExpression">Expression used to find field name</param>
        /// <param name="values">Values to find</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> FilterIf <TDocument, TValue>(this DocumentSearch <TDocument> documentSearch, Func <bool> conditional, Expression <Func <TDocument, object> > fieldExpression, params TValue[] values)
            where TDocument : Document
        {
            Checker.IsNull(conditional);

            if (conditional.Invoke())
            {
                documentSearch.Filter(fieldExpression, values);
            }

            return(documentSearch);
        }
        /// <summary>
        /// Create a limit and a offset parameters
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="conditional">Conditional to add parameter</param>
        /// <param name="itemsPerPage">Quantity of items in one page</param>
        /// <param name="currentPage">Current page</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> PageIf <TDocument>(this DocumentSearch <TDocument> documentSearch, Func <bool> conditional, long itemsPerPage, long currentPage)
            where TDocument : Document
        {
            Checker.IsNull(conditional);

            if (conditional.Invoke())
            {
                documentSearch.Page(itemsPerPage, currentPage);
            }

            return(documentSearch);
        }
        /// <summary>
        /// Create a query field parameter
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="conditional">Conditional to add parameter</param>
        /// <param name="expression">Query used to make query field</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> QueryFieldIf <TDocument>(this DocumentSearch <TDocument> documentSearch, Func <bool> conditional, string expression)
            where TDocument : Document
        {
            Checker.IsNull(conditional);

            if (conditional.Invoke())
            {
                documentSearch.QueryField(expression);
            }

            return(documentSearch);
        }
        /// <summary>
        /// Create a fields parameter
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="conditional">Conditional to add parameter</param>
        /// <param name="fieldExpressions">Expressions used to find fields name</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> FieldsIf <TDocument>(this DocumentSearch <TDocument> documentSearch, Func <bool> conditional, params Expression <Func <TDocument, object> >[] fieldExpressions)
            where TDocument : Document
        {
            Checker.IsNull(conditional);

            if (conditional.Invoke())
            {
                documentSearch.Fields(fieldExpressions);
            }

            return(documentSearch);
        }
        /// <summary>
        /// Create a spatial filter parameter
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="conditional">Conditional to add parameter</param>
        /// <param name="fieldExpression">Expression used to find field name</param>
        /// <param name="functionType">Function used in spatial filter</param>
        /// <param name="centerPoint">Center point to spatial filter</param>
        /// <param name="distance">Distance from center point</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> SpatialFilterIf <TDocument>(this DocumentSearch <TDocument> documentSearch, Func <bool> conditional, Expression <Func <TDocument, object> > fieldExpression, GeoCoordinate centerPoint, decimal distance, SpatialFunctionType functionType = SpatialFunctionType.Bbox)
            where TDocument : Document
        {
            Checker.IsNull(conditional);

            if (conditional.Invoke())
            {
                documentSearch.SpatialFilter(fieldExpression, centerPoint, distance, functionType);
            }

            return(documentSearch);
        }
        public void IndexedSearchTest()
        {
            // Arrange
            var termToTest = "massa";
            var totalCount = 14;

            // Act
            int result = DocumentSearch.IndexedSearch(testData, termToTest);

            // Assert
            Assert.AreEqual(result, totalCount);
        }
        /// <summary>
        /// Create a facet limit parameter
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="conditional">Conditional to add parameter</param>
        /// <param name="value">Value of limit</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> FacetLimitIf <TDocument>(this DocumentSearch <TDocument> documentSearch, Func <bool> conditional, int value)
            where TDocument : Document
        {
            Checker.IsNull(conditional);

            if (conditional.Invoke())
            {
                documentSearch.FacetLimit(value);
            }

            return(documentSearch);
        }
        /// <summary>
        /// Create a sort parameter configured to do a random sort
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="conditional">Conditional to add parameter</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> SortRandomlyIf <TDocument>(this DocumentSearch <TDocument> documentSearch, Func <bool> conditional)
            where TDocument : Document
        {
            Checker.IsNull(conditional);

            if (conditional.Invoke())
            {
                documentSearch.SortRandomly();
            }

            return(documentSearch);
        }
        /// <summary>
        /// Create a sort parameter
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="conditional">Conditional to add parameter</param>
        /// <param name="fieldExpression">Expressions used to find field name</param>
        /// <param name="ascendent">True to ascendent order, otherwise false</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> SortIf <TDocument>(this DocumentSearch <TDocument> documentSearch, Func <bool> conditional, Expression <Func <TDocument, object> > fieldExpression, bool ascendent = true)
            where TDocument : Document
        {
            Checker.IsNull(conditional);

            if (conditional.Invoke())
            {
                documentSearch.Sort(fieldExpression, ascendent);
            }

            return(documentSearch);
        }
        /// <summary>
        /// Create a boost parameter
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="conditional">Conditional to add parameter</param>
        /// <param name="query">Query used to make boost</param>
        /// <param name="instance">Instance of boost ready to configure</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> BoostIf <TDocument>(this DocumentSearch <TDocument> documentSearch, Func <bool> conditional, Action <SearchQuery <TDocument> > query, Action <IBoostParameter <TDocument> > instance = null)
            where TDocument : Document
        {
            Checker.IsNull(conditional);

            if (conditional.Invoke())
            {
                documentSearch.Boost(query, instance);
            }

            return(documentSearch);
        }
        /// <summary>
        /// Create a sort parameter
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="fieldExpression">Expressions used to find field name</param>
        /// <param name="ascendent">True to ascendent order, otherwise false</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> Sort <TDocument>(this DocumentSearch <TDocument> documentSearch, Expression <Func <TDocument, object> > fieldExpression, bool ascendent = true)
            where TDocument : Document
        {
            var parameter = documentSearch.ServiceProvider.GetService <ISortParameter <TDocument> >();

            parameter.FieldExpression(fieldExpression);
            parameter.Ascendent(ascendent);

            documentSearch.Add(parameter);

            return(documentSearch);
        }
        /// <summary>
        /// Create a query parameter
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="conditional">Conditional to add parameter</param>
        /// <param name="fieldExpression">Expression used to find field name</param>
        /// <param name="query">Query used to make filter</param>
        /// <param name="instance">Instance of parameter ready to configure</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> QueryIf <TDocument>(this DocumentSearch <TDocument> documentSearch, Func <bool> conditional, Expression <Func <TDocument, object> > fieldExpression, Action <SearchQuery <TDocument> > query, Action <IQueryParameter <TDocument> > instance = null)
            where TDocument : Document
        {
            Checker.IsNull(conditional);

            if (conditional.Invoke())
            {
                documentSearch.Query(fieldExpression, query, instance);
            }

            return(documentSearch);
        }
        /// <summary>
        /// Create a query parameter in commom case (value to be processed using QueryField)
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="conditional">Conditional to add parameter</param>
        /// <param name="values">Values to find</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> QueryIf <TDocument, TValue>(this DocumentSearch <TDocument> documentSearch, Func <bool> conditional, params TValue[] values)
            where TDocument : Document
        {
            Checker.IsNull(conditional);

            if (conditional.Invoke())
            {
                documentSearch.Query(values);
            }

            return(documentSearch);
        }
        /// <summary>
        /// Create a not mapped parameter
        /// </summary>
        /// <param name="documentSearch">Document search engine</param>
        /// <param name="conditional">Conditional to add parameter</param>
        /// <param name="name">Name of parameter</param>
        /// <param name="value">Value of parameter</param>
        /// <returns>Document search engine</returns>
        public static DocumentSearch <TDocument> AnyIf <TDocument>(this DocumentSearch <TDocument> documentSearch, Func <bool> conditional, string name, string value)
            where TDocument : Document
        {
            Checker.IsNull(conditional);

            if (conditional.Invoke())
            {
                documentSearch.Any(name, value);
            }

            return(documentSearch);
        }
Beispiel #31
0
        public int GetTotalCount(DocumentSearch wrapper)
        {
            if (wrapper == null)
                throw new ArgumentNullException("wrapper and pageinfo  is null");

            SqlServerUtility sql = new SqlServerUtility();

            if (!string.IsNullOrEmpty(wrapper.Title))
            {
                sql.AddParameter("@title", SqlDbType.NVarChar, wrapper.Title);
            }

            if (wrapper.State != null && wrapper.State.HasValue)
            {
                sql.AddParameter("@state", SqlDbType.Int, wrapper.State.Value);
            }
            if (wrapper.Secret != null && wrapper.Secret.HasValue)
            {
                sql.AddParameter("@secret", SqlDbType.Int, wrapper.Secret.Value);
            }
            if (wrapper.Mergency != null && wrapper.Mergency.HasValue)
            {
                sql.AddParameter("@mergency", SqlDbType.Int, wrapper.Mergency.Value);
            }
            if (wrapper.Sender != null && wrapper.Sender.HasValue)
            {
                sql.AddParameter("@sender", SqlDbType.Int, wrapper.Sender.Value);
            }
            if (wrapper.Reciever != null && wrapper.Reciever.HasValue)
            {
                sql.AddParameter("@reciever", SqlDbType.Int, wrapper.Reciever.Value);
            }
            if (wrapper.RecieverState != null && wrapper.RecieverState.HasValue)
            {
                sql.AddParameter("@desstate", SqlDbType.Int, wrapper.RecieverState.Value);
            }

            int totalCount = 0;

            SqlDataReader reader = sql.ExecuteSPReader("usp_GetTotalCountForDocument");

            if (reader != null && !reader.IsClosed && reader.Read())
            {
                if (!reader.IsDBNull(0)) totalCount = reader.GetInt32(0);
                reader.Close();
            }
            return totalCount;
        }
Beispiel #32
0
        public IEnumerable<Document> Search(DocumentSearch wrapper, CY.GFive.Core.Business.PagingInfo pageinfo)
        {
            if (wrapper == null || pageinfo == null)
                throw new ArgumentNullException("wrapper and pageinfo  is null");

            SqlServerUtility sql = new SqlServerUtility();

            if (!string.IsNullOrEmpty(wrapper.Title))
            {
                sql.AddParameter("@title", SqlDbType.NVarChar, wrapper.Title);
            }

            if (wrapper.State != null && wrapper.State.HasValue)
            {
                sql.AddParameter("@state", SqlDbType.Int, wrapper.State.Value);
            }
            if (wrapper.Secret != null && wrapper.Secret.HasValue)
            {
                sql.AddParameter("@secret", SqlDbType.Int, wrapper.Secret.Value);
            }
            if (wrapper.Mergency != null && wrapper.Mergency.HasValue)
            {
                sql.AddParameter("@mergency", SqlDbType.Int, wrapper.Mergency.Value);
            }
            if (wrapper.Sender != null && wrapper.Sender.HasValue)
            {
                sql.AddParameter("@sender", SqlDbType.Int, wrapper.Sender.Value);
            }
            if (wrapper.Reciever != null && wrapper.Reciever.HasValue)
            {
                sql.AddParameter("@reciever", SqlDbType.Int, wrapper.Reciever.Value);
            }
            if (wrapper.RecieverState != null && wrapper.RecieverState.HasValue)
            {
                sql.AddParameter("@desstate", SqlDbType.Int, wrapper.RecieverState.Value);
            }

            int lowBand = (pageinfo.CurrentPage - 1) * pageinfo.PageSize;

            int highBand = pageinfo.CurrentPage * pageinfo.PageSize;

            sql.AddParameter("@lowband", SqlDbType.Int, lowBand);

            sql.AddParameter("@highband", SqlDbType.Int, highBand);

            IList<Core.Business.Document> documentlist = new List<Core.Business.Document>();

            SqlDataReader reader = sql.ExecuteSPReader("usp_SearchDocument");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Document document = new Core.Business.Document();

                    if (!reader.IsDBNull(0)) document.Id = reader.GetInt64(0);
                    if (!reader.IsDBNull(1)) document.Title = reader.GetString(1);
                    if (!reader.IsDBNull(2)) document.SubTitle = reader.GetString(2);
                    if (!reader.IsDBNull(3)) document.Content = reader.GetString(3);
                    if (!reader.IsDBNull(4)) document.SendDate = reader.GetDateTime(4);
                    if (!reader.IsDBNull(5)) document.State = reader.GetInt32(5);
                    if (!reader.IsDBNull(6)) document.Secret = reader.GetInt32(6);
                    if (!reader.IsDBNull(7)) document.Mergency = reader.GetInt32(7);
                    if (!reader.IsDBNull(8)) document.DraftDate = reader.GetDateTime(8);
                    if (!reader.IsDBNull(9)) document.Sender = reader.GetInt32(9);

                    document.MarkOld();
                    documentlist.Add(document);
                }
                reader.Close();
            }
            return documentlist;
        }