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 202817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:19:24+00:00 2026-05-11T17:19:24+00:00

I am trying to perform what I can only describe as the reverse version

  • 0

I am trying to perform what I can only describe as the reverse version of IN() using the Nhibernate Criteria..

Rather than saying the value stored in the property is in the list/collection X

I want to say, this value X (an ID) is in the list which is a property of the object.

Any help appreciated, I can try to explain better if this makes no sense.

EDIT Apologies to people, as I understand this doesn’t make enough sense…

I have an Event item in my system which can have a list of Audience (items) which it applies to. If the admin wants to delete an Audience item I want to check that the item is not referenced by any events. (The AudienceList is stored as a string list of IDs for Audiences).

What I was thinking was something along the lines of:

var results = SessionInstance.Session.CreateCriteria(typeof(EventItem.Items.EventItem)) .Add(Restrictions.In(“AudienceList”, myAudience.ID))
.List();

But I need the AudienceList and myAudience.ID to be the other way around don’t I? I have the audience ID but need to check that it might be in a list of other ids.

Thanks again.

EDIT 2

The definition of the EventItem is such that one of it’s properties is a DetailCollection of Audience IDs, they are saved to the DB as a string list of IDs.

  • 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-11T17:19:24+00:00Added an answer on May 11, 2026 at 5:19 pm

    EDIT: Scrapped my previous answer.

    Well, it sounds like there is not a true relational model here so things will not be as pretty. Without foreign keys and the like, I’m not sure NHibernate will be much use in this situation (at least to generate a nice query).

    If all of the Audience IDs for a single Event record are stored in a single field , you’ll either have to use a SQL LIKE or do it in code. Fetch all the EventItems and iterate through them, checking their AudienceList collections for the ID you’re looking for. If you go that route, it might be best to create a DTO to minimize the amount of data you move around. Something like

    session.CreateQuery("select new AudienceListDTO(e.AudienceList) from EventItems e").List();
    

    That’s assuming you just need to inform the user that “this audience type is still in use” and not point out specific instances. Otherwise you’ll have to add more data.

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

Sidebar

Ask A Question

Stats

  • Questions 124k
  • Answers 124k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer No, there is no "intrinsic" way of knowing that (e.g.)… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer Here's a complete guess at some code that might load… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer It's possible but only to a degree. You're going to… May 12, 2026 at 1:19 am

Related Questions

I'm working with a legacy WebLogic application that contains a web-service application and a
I am doing some work to track down a perceived bug in a git
I would really appreciate some feedback on what I am trying to achieve: The
I'm trying to perform some offline maintenance (dev database restore from live backup) on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.