/// <summary>
        /// 
        /// </summary>
        /// <param name="rootAlias"></param>
        /// <param name="rootType"></param>
        /// <param name="matchMode"></param>
        /// <param name="entityMode"></param>
        /// <param name="instance"></param>
        /// <param name="classInfoProvider"></param>
        public CriteriaCompiled(string rootAlias, System.Type rootType, MatchMode matchMode, EntityMode entityMode,
                                object instance, Func<System.Type, IPersistentClassInfo> classInfoProvider)
        {
            
            if (rootAlias == null || rootAlias.Trim().Equals(string.Empty))
                throw new ArgumentException("The alias for making detached criteria cannot be empty or null", "rootAlias");

            if (rootType == null)
                throw new ArgumentNullException("rootType", "The type which can be used for maikng detached criteria cannot be null.");

            if (instance == null)
                throw new ArgumentNullException("instance", "The instance for building detached criteria cannot be null.");

            if (!rootType.IsInstanceOfType(instance))
                throw new ArgumentTypeException("The given instance for building detached criteria is not suitable for the given criteria type.", "instance", rootType, instance.GetType());

            this.matchMode = matchMode ?? MatchMode.Exact;
            this.entityMode = entityMode;
            this.instance = instance;
            this.classInfoProvider = classInfoProvider;

            this.relationshipTree = new RelationshipTree(rootAlias, rootType);
            this.criteria = DetachedCriteria.For(rootType, rootAlias);
            this.restrictions = new List<ICriterion>();
            this.Init();
        }
 public InsensitiveLikeIncludeNullExpression(string propertyName, string value, MatchMode matchMode) {
     if(value != null)
         _criterion = Restrictions.Disjunction()
             .Add(Restrictions.InsensitiveLike(propertyName, value, matchMode))
             .Add(Restrictions.IsNull(propertyName));
     else
         _criterion = Restrictions.IsNull(propertyName);
 }
        public InsensitiveLikeIncludeNullExpression(IProjection projection, string value, MatchMode matchMode) {
            _projection = projection;

            if(value != null)
                _criterion = Restrictions.Disjunction()
                    .Add(Restrictions.InsensitiveLike(projection, value, matchMode))
                    .Add(Restrictions.IsNull(projection));
            else
                _criterion = Restrictions.IsNull(projection);
        }
Esempio n. 4
0
        public static string ToMatchString(this string matchString, MatchMode matchMode) {
            if(matchMode == MatchMode.Exact)
                return matchString;
            if(matchMode == MatchMode.Start)
                return matchString + '%';
            if(matchMode == MatchMode.End)
                return '%' + matchString;
            if(matchMode == MatchMode.Anywhere)
                return '%' + matchString + '%';

            return matchString;
        }
        /// <summary>
        /// 리소스 이름으로 매칭된 리소스 정보를 조회합니다.
        /// </summary>
        /// <param name="product">제품</param>
        /// <param name="nameToMatch">검색하고자 하는 리소스 명</param>
        /// <param name="matchMode">매칭 모드</param>
        /// <returns></returns>
        public IList<Resource> FindAllResourceByNameToMatch(Product product, string nameToMatch, MatchMode matchMode)
        {
            product.ShouldNotBeNull("product");

            if(IsDebugEnabled)
                log.Debug(@"Resource 정보를 Name 매칭 검색으로 조회합니다... product={0}, nameToMatch=[{1}], matchMode={2}",
                          product, nameToMatch, matchMode);

            var query =
                BuildQueryOverOfResource(product)
                    .AddInsensitiveLike(r => r.Name, nameToMatch, matchMode ?? MatchMode.Anywhere);

            return Repository<Resource>.FindAll(query);
        }
Esempio n. 6
0
		public LikeExpression(IProjection projection, string value, MatchMode matchMode)
		{
			this.projection = projection;
			this.value = matchMode.ToMatchString(value);
			typedValue = new TypedValue(NHibernateUtil.String, this.value, EntityMode.Poco);
		}
Esempio n. 7
0
 public static AbstractCriterion Like(string propertyName, string template, MatchMode matchMode)
 {
     return new LikeExpression(propertyName, matchMode.ToMatchString(template).ToLocalizableLikeClause(), MatchMode.Exact, null, false);
 }
        /// <summary>
        /// 지정된 아이템 이름과 매칭되는 모든 코드 정보를 조회합니다.
        /// </summary>
        /// <param name="companyCode">회사</param>
        /// <param name="itemNameToMatch">검색할 코드 아이템 명</param>
        /// <param name="matchMode">매칭 모드</param>
        /// <param name="firstResult">첫번째 결과 셋의 인덱스 (0부터 시작. null이면 0으로 간주)</param>
        /// <param name="maxResults">결과 셋의 최대 레코드 수 (null 또는 0 이하의 값은 무시된다)</param>
        /// <param name="orders">정렬 순서</param>
        /// <returns></returns>
        public IList<Code> FindAllCodeByItemNameToMatch(string companyCode,
                                                        string itemNameToMatch,
                                                        MatchMode matchMode,
                                                        int? firstResult,
                                                        int? maxResults,
                                                        params INHOrder<Code>[] orders)
        {
            if(IsDebugEnabled)
                log.Debug(@"지정된 아이템 이름과 매칭되는 모든 코드 정보를 조회합니다... " +
                          @"company={0}, itemNameToMatch={1}, matchMode={2}, firstResult={3}, maxResults={4}, orders={5}",
                          companyCode, itemNameToMatch, matchMode, firstResult, maxResults, orders);

            var query = QueryOver.Of<Code>();

            if(companyCode.IsNotWhiteSpace())
                query.AddWhere(c => c.Group.CompanyCode == companyCode);

            if(itemNameToMatch.IsNotWhiteSpace())
                query.AddInsensitiveLike(c => c.ItemName, itemNameToMatch, matchMode ?? MatchMode.Anywhere);

            return Repository<Code>.FindAll(query.AddOrders(orders),
                                            firstResult.GetValueOrDefault(),
                                            maxResults.GetValueOrDefault());
        }
        /// <summary>
        /// 제품명 매칭 검색을 수행합니다.
        /// </summary>
        /// <param name="nameToMatch">매칭 검색할 제품명</param>
        /// <param name="matchMode">매칭 모드</param>
        /// <returns></returns>
        public IList<Product> FindAllProductByNameToMatch(string nameToMatch, MatchMode matchMode)
        {
            if(IsDebugEnabled)
                log.Debug(@"제품명 매칭 검색을 수행합니다... nameToMatch={0}, matchMode={1}", nameToMatch, matchMode);

            var query = QueryOver.Of<Product>().AddInsensitiveLike(p => p.Name, nameToMatch, matchMode ?? MatchMode.Anywhere);
            return Repository<Product>.FindAll(query);
        }
Esempio n. 10
0
		public AbstractCriterion Like(String value, MatchMode matchMode)
		{
			return Expression.Like(PropertyName, value, matchMode);
		}
Esempio n. 11
0
 public LikeExpression(IProjection projection, string value, MatchMode matchMode)
 {
     this.projection = projection;
     this.value      = matchMode.ToMatchString(value);
     typedValue      = new TypedValue(NHibernateUtil.String, this.value);
 }
Esempio n. 12
0
        /// <summary>
        /// Resource 정보를 Name 매칭 검색 결과를 Paging처리해서 로드합니다.
        /// </summary>
        /// <param name="product">제품</param>
        /// <param name="nameToMatch">검색하고자 하는 리소스 명</param>
        /// <param name="matchMode">매칭 모드</param>
        /// <param name="pageIndex">페이지 인덱스 (0부터 시작)</param>
        /// <param name="pageSize">페이지 크기 (0보다 커야 한다. 보통 10)</param>
        /// <param name="orders">정렬 순서</param>
        /// <returns></returns>
        public IPagingList<Resource> GetPageOfResourceByNameToMatch(Product product, string nameToMatch, MatchMode matchMode,
                                                                    int pageIndex, int pageSize, params INHOrder<Resource>[] orders)
        {
            product.ShouldNotBeNull("product");
            pageIndex.ShouldBePositiveOrZero("pageIndex");
            pageSize.ShouldBePositive("pageSize");

            if(IsDebugEnabled)
                log.Debug(@"Resource 정보를 Name 매칭 검색 결과를 Paging처리해서 로드합니다... " +
                          @"product={0}, nameToMatch={1}, matchMode={2}, pageIndex={3}, pagesize={4}, orders={5}",
                          product, nameToMatch, matchMode, pageIndex, pageSize, orders);

            var query =
                BuildQueryOverOfResource(product)
                    .AddInsensitiveLike(r => r.Name, nameToMatch, matchMode ?? MatchMode.Anywhere);

            return Repository<Resource>.GetPage(pageIndex, pageSize, query, orders);
        }
Esempio n. 13
0
        /// <summary>
        /// 지정된 회사에서, 지정된 이름과 매칭되는 (LIKE 검색) 사용자 정보를 조회합니다.
        /// </summary>
        /// <param name="company"></param>
        /// <param name="nameToMatch"></param>
        /// <param name="matchMode"></param>
        /// <returns></returns>
        public IList<User> FindAllUserByCompanyAndNameToMatch(Company company, string nameToMatch, MatchMode matchMode)
        {
            company.ShouldNotBeNull("company");

            if(IsDebugEnabled)
                log.Debug("사용자 이름과 매칭 검색을 수행합니다. nameToMatch={0}, matchMode={1}", nameToMatch, matchMode);

            var query =
                QueryOver.Of<User>()
                    .AddWhere(u => u.Company == company)
                    .AddInsensitiveLike(u => u.Name, nameToMatch, matchMode ?? MatchMode.Anywhere);

            return Repository<User>.FindAll(query);
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="InsensitiveLikeExpression"/> class.
		/// </summary>
		/// <param name="projection">The projection.</param>
		/// <param name="value">The value.</param>
		/// <param name="matchMode">The match mode.</param>
		public InsensitiveLikeExpression(IProjection projection, string value, MatchMode matchMode)
		{
			this.projection = projection;
			this.value = matchMode.ToMatchString(value);
		}
Esempio n. 15
0
 public LikeExpression(string propertyName, string value, MatchMode matchMode, char?escapeChar, bool ignoreCase)
     : this(propertyName, matchMode.ToMatchString(value), escapeChar, ignoreCase)
 {
 }
Esempio n. 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InsensitiveLikeExpression"/> class.
 /// </summary>
 /// <param name="projection">The projection.</param>
 /// <param name="value">The value.</param>
 /// <param name="matchMode">The match mode.</param>
 public InsensitiveLikeExpression(IProjection projection, string value, MatchMode matchMode)
 {
     this.projection = projection;
     this.value      = matchMode.ToMatchString(value);
 }
Esempio n. 17
0
        /// <summary>
        /// 메뉴 템플릿 이름이 매칭되는 검색을 수행합니다.
        /// </summary>
        public IList<MenuTemplate> FindAllMenuTemplateByNameToMatch(Product product, string nameToMatch, MatchMode matchMode, params INHOrder<MenuTemplate>[] orders)
        {
            product.ShouldNotBeNull("product");

            if(IsDebugEnabled)
                log.Debug(@"지정한 제품의 모든 MenuTemplate 정보를 조회합니다... product={0}, nameToMatch={1}, matchMode={2}, orders={3}",
                          product, nameToMatch, matchMode, orders.CollectionToString());

            var query =
                BuildQueryOverOfMenuTemplate(product, null, null)
                    .AddInsensitiveLike(mt => mt.Name, nameToMatch, matchMode ?? MatchMode.Anywhere)
                    .AddOrders(orders);

            return Repository<MenuTemplate>.FindAll(query);
        }
Esempio n. 18
0
		public LikeExpression(string propertyName, string value, MatchMode matchMode, char? escapeChar, bool ignoreCase)
			: this(propertyName, matchMode.ToMatchString(value), escapeChar, ignoreCase)
		{
		}
		/// <summary>
		/// Apply a "like" restriction in a QueryOver expression
		/// Note: throws an exception outside of a QueryOver expression
		/// </summary>
		public static bool IsInsensitiveLike(this string projection, string comparison, MatchMode matchMode)
		{
			throw new Exception("Not to be used directly - use inside QueryOver expression");
		}
 /// <summary>
 /// 
 /// </summary>
 /// <param name="rootType"></param>
 /// <param name="matchMode"></param>
 /// <param name="entityMode"></param>
 /// <param name="instance"></param>
 /// <param name="classInfoProvider"></param>
 internal CriteriaCompiled(System.Type rootType, MatchMode matchMode, EntityMode entityMode,
                         object instance, Func<System.Type, IPersistentClassInfo> classInfoProvider)
     //:this(rootType.Name.Lower(), rootType, matchMode, entityMode, instance, classInfoProvider)
     : this(rootType.Name.ToCamelCase(), rootType, matchMode, entityMode, instance, classInfoProvider)
 {
 }
Esempio n. 21
0
 public InsensitiveLikeExpression(string propertyName, string value, MatchMode matchMode)
     : this(propertyName, matchMode.ToMatchString(value))
 {
 }
		public InsensitiveLikeExpression(string propertyName, string value, MatchMode matchMode)
			: this(propertyName, matchMode.ToMatchString(value))
		{
		}
 private ICriterion GetLikeCriteria(MethodCallExpression expr, MatchMode matchMode)
 {
     return Restrictions.Like(MemberNameVisitor.GetMemberName(rootCriteria, expr.Object),
                              String.Format("{0}", QueryUtil.GetExpressionValue(expr.Arguments[0])),
                              matchMode);
 }
		/// <summary>
		/// Apply a "like" restriction in a QueryOver expression
		/// Note: throws an exception outside of a QueryOver expression
		/// </summary>
		public static bool IsLike(this string projection, string comparison, MatchMode matchMode, char? escapeChar)
		{
			throw new Exception("Not to be used directly - use inside QueryOver expression");
		}
        /// <summary>
        /// 조직명 매칭 검색 (LIKE 검색)을 수행합니다.
        /// </summary>
        /// <param name="company">소속 회사</param>
        /// <param name="nameToMatch">검색할 조직명</param>
        /// <param name="matchMode">검색 매칭 모드</param>
        /// <param name="firstResult">첫번째 결과 셋의 인덱스 (0부터 시작. null이면 0으로 간주)</param>
        /// <param name="maxResults">결과 셋의 최대 레코드 수 (null 또는 0 이하의 값은 무시된다)</param>
        /// <param name="orders">정렬 순서</param>
        /// <returns></returns>
        public IList<Department> FindAllDepartmentByNameToMatch(Company company, string nameToMatch, MatchMode matchMode, int? firstResult, int? maxResults,
                                                                params INHOrder<Department>[] orders)
        {
            company.ShouldNotBeNull("company");

            if(nameToMatch.IsWhiteSpace())
                return FindAllDepartmentByCompany(company, firstResult, maxResults, orders);

            if(IsDebugEnabled)
                log.Debug(@"조직명 매칭 검색 (LIKE 검색)을 수행합니다... " +
                          @"company={0}, nameToMatch={1}, matchMode={2}, firstResult={3}, maxResults={4}, orders={5}",
                          company.Code, nameToMatch, matchMode, firstResult, maxResults, orders.CollectionToString());

            var query =
                QueryOver.Of<Department>()
                    .AddWhere(dept => dept.Company == company)
                    .AddInsensitiveLike(dept => dept.Name, nameToMatch, matchMode ?? MatchMode.Anywhere)
                    .AddOrders(orders);

            return Repository<Department>.FindAll(query,
                                                  firstResult.GetValueOrDefault(),
                                                  maxResults.GetValueOrDefault());
        }
Esempio n. 26
0
		/// <summary>
		/// Use the "like" operator for all string-valued properties with
		/// the specified <see cref="MatchMode"/>.
		/// </summary>
		/// <param name="matchMode">
		/// The <see cref="MatchMode"/> to convert the string to the pattern
		/// for the <c>like</c> comparison.
		/// </param>
		public Example EnableLike(MatchMode matchMode)
		{
			_isLikeEnabled = true;
			_matchMode = matchMode;
			return this;
		}
 private ICriterion GetLikeCriteria(MethodCallExpression expr, MatchMode matchMode)
 {
     var member = MemberNameVisitor.GetMemberName(rootCriteria, expr.Object);
     var val = String.Format("{0}", QueryUtil.GetExpressionValue(expr.Arguments[0]));
     // Using '!' as escape instead of '\' to avoid postgresql issues with '\'.. (pruiz)
     val = val.Replace(@"!", @"!!").Replace("%", @"!%").Replace("_", @"!_");
     return Restrictions.Like(member, val, matchMode, '!');
 }