Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 865175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:36:00+00:00 2026-05-15T09:36:00+00:00

small questions about Restrictions. i have query like this : Where A in(1,6) and

  • 0

small questions about Restrictions.

i have query like this :

Where  A in(1,6) and (B not like 'Value%' or B not like 'ValueII%')

the problem is the field B not contains a fixed value, can be one or more.

Please, (N)Hibernate experts – help me with this, I cant find a working solution. Any help is greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T09:36:00+00:00Added an answer on May 15, 2026 at 9:36 am

    You can use disjunctions to handle the OR cases, as such:

    IList results = session.CreateCriteria(typeof(MyType))
        .Add(Restrictions.In("A", new [] {1, 6}))
        .Add(Restrictions.Disjunction()
            .Add.Restrictions.Not(Restrictions.Like("B", "Value%"))
            .Add.Restrictions.Not(Restrictions.Like("B", "ValueII%")))
        .List<MyType>();
    

    If you need to handle the disjunction conditions in a for loop (per your follow-up), you can use code like this:

    ICriteria query = session.CreateCriteria(typeof(MyType));
    query.Add(Restrictions.In("A", new [] {1, 6}))
    
    Disjunction disjunction = Restrictions.Disjunction();
    foreach (var value in values) {
        disjunction.Add(Restrictions.Not(Restrictions.Like(value, "Value%")));
        disjunction.Add(Restrictions.Not(Restrictions.Like(value, "ValueII%")));
    }
    query.Add(disjunction);
    
    IList results = query.List<MyType>();
    

    That being said, I think there may be a flaw in your logic. If you are testing these values to “not match one pattern OR not match another pattern”, then the condition will always evaluate to true (unless the patterns are the same). Are you sure you want to be using ORs here?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

small questions about Restrictions.or and Restrictions.and If I do something like this: ... criterion
I have spent several days now researching Hibernate and have several small questions about
I have a question about a small problem I am having in Magento. When
This question is not about caching. I need this in-memory table for many small
I have two Questions. One small and one greater problem. Why i have to
i searched for this Problem, and i found some stackoverflow Questions about the same
I have two small problems/questions about app development in Windows Phone 7. 1: I
I've got a couple of questions about this small snippett adapted from a tutorial
Hello guys I have two small questions about my facebook application link and JS
I am mapping out a very small database and have some design questions about

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.