예제 #1
0
        /// <summary>
        /// A helper method used for building the query, depending on if the LoadLazy option was set.
        /// </summary>
        /// <typeparam name="T">A query over object required by the QueryOver Method on the repository</typeparam>
        /// <param name="request">The same request passed into the service</param>
        /// <param name="hasWhere">a bool value indicating if there is a where string</param>
        /// <returns></returns>
        private Expression <Func <T, bool> > BuildQuery <T>(FindJarsRules request) where T : JarsRule
        {
            Expression <Func <T, bool> > query = LinqExpressionBuilder.True <T>();

            if (!request.TargetEntityTypeName.IsNullOrEmpty())
            {
                query = query.And(o => o.TargetTypeName == request.TargetEntityTypeName);
            }

            if (!request.SourceEntityTypeName.IsNullOrEmpty())
            {
                query = query.And(o => o.SourceTypeName == request.SourceEntityTypeName);
            }

            return(query);
        }
예제 #2
0
        public object Any(FindJarsRules request)
        {
            //return ExecuteFaultHandledMethod(() =>
            //{
            JarsRulesResponse response = new JarsRulesResponse();

            if (request != null)
            {
                var query       = BuildQuery <JarsRule>(request);
                var _repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <JarsRule, IDataContextNhJars> >();
                //because the EntityRule is a core class and is used as is, there is no need for dtos or transformations. :-)
                response.Rules = _repository.Where(query, true).ToList();
            }
            return(response);
            //});
        }