Ejemplo n.º 1
0
        /// <summary>
        /// This method issues a search request.
        /// </summary>
        /// <param name="rq">The search request.</param>
        /// <param name="settings">The persistence request settings.</param>
        /// <returns>The search response.</returns>
        public virtual async Task <RepositoryHolder <SearchRequest, SearchResponse> > Search(SearchRequest rq, RepositorySettings settings = null)
        {
            //if ((settings?.UseCache ?? true) && mCacheManager.IsActive)
            //{
            //    var result = await mCacheManager.VersionRead(new Tuple<string, string>(refKey, refValue));
            //    if (result.IsSuccess)
            //    {
            //        return new RepositoryHolder<K, Tuple<K, string>>(result.Entity.Item1, new Tuple<string, string>(result.Id, result.VersionId), responseCode: 200, entity: result.Entity) { IsCached = true };
            //    }
            //}

            return(await TransmitInternal(EntityActions.Search, new RepositoryHolder <SearchRequest, SearchResponse> {
                Key = rq, Settings = settings
            }, principal : DefaultPrincipal));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The internal search command.
        /// </summary>
        /// <param name="key">The search request.</param>
        /// <param name="holder">The request holder.</param>
        /// <returns></returns>
        protected async override Task <IResponseHolder <SearchResponse> > InternalSearch(SearchRequest key, PersistenceRequestHolder <SearchRequest, SearchResponse> holder)
        {
            var query = mContainer.Values.AsQueryable <E>();

            Expression expression = mTransform.SearchTranslator.Build(key);

            //Execute Expression on Query
            bool success = true; //for the time being since we are not executing any queries

            holder.Rs.Entity = new SearchResponse();
            List <JObject> jObjects = new List <JObject>();

            foreach (var source in query.ToList())
            {
                jObjects.Add(JObject.FromObject(source));
            }
            if (success)
            {
                var resultEntities = query.ToList();
                holder.Rs.Entity.Data = jObjects;
                return(new PersistenceResponseHolder <SearchResponse>(PersistenceResponse.Ok200, null, holder.Rs.Entity));
            }



            //holder.Rs.
            //key.Select
            ////Create the expression parameters
            //ParameterExpression num1 = Expression.Parameter(typeof(E), "num1");
            //ParameterExpression num2 = Expression.Parameter(typeof(E), "num2");

            ////Create the expression parameters
            //ParameterExpression[] parameters = new ParameterExpression[] { num1, num2 };

            ////Create the expression body
            //BinaryExpression body = Expression.Add(num1, num2);
            ////Expression predicateBody = Expression.OrElse(e1, e2);
            ////Create the expression
            //Expression<Func<int, int, int>> expression = Expression.Lambda<Func<int, int, int>>(body, parameters);

            //// Compile the expression
            //Func<int, int, int> compiledExpression = expression.Compile();

            //// Execute the expression.
            //int result = compiledExpression(3, 4);

            return(await base.InternalSearch(key, holder));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// This method reads an entity based on the key passed.
 /// </summary>
 /// <param name="key">The key request.</param>
 /// <param name="options">These are the repository options which define the request type..</param>
 /// <returns>This is the holder containing the response and the entity where necessary.</returns>
 public virtual async Task <RepositoryHolder <SearchRequest, SearchResponse> > Search(SearchRequest key, RepositorySettings options = null)
 {
     throw new NotSupportedException();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Builds the specified expression base on the search request..
 /// </summary>
 /// <param name="key">The search request..</param>
 /// <returns>Returns the expression.</returns>
 public Expression Build(SearchRequest key)
 {
     return(null);
 }