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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:52:51+00:00 2026-05-11T19:52:51+00:00

I have a simple Waiver model, and I would like to make a query

  • 0

I have a simple Waiver model, and I would like to make a query that returns all the Waivers that are not overridden.

public class Waiver
{
    private readonly int id;

    protected Waiver()
    {
        this.id = 0;
    }

    public virtual int Id { get { return id; } }

    public virtual string Name { get; set; }
    public virtual string Description { get; set; }
    public virtual bool IsRequired { get; set; }
    public virtual DateTime EffectiveDate { get; set; }

    public virtual Waiver OverriddenWaiver { get; set; }
}

Here’s the map:

  <class name="Waiver" table="Music_Waivers">
    <id name="id" access="field" column="WaiverId" unsaved-value="0">
      <generator class="native" />
    </id>

    <property name="Name" column="Name" />
    <property name="Description" column="Description" />
    <property name="IsRequired" column="IsRequired" />
    <property name="EffectiveDate" column="EffectiveDate" />

    <many-to-one name="OverriddenWaiver" class="Waiver" column="OverrideWaiverId" />
  </class>

Now I want to have a method in my Repository with the signature public IList GetLatest(). For some reason I’m having a hard time implementing this with the CriteriaAPI. I can write this in T-SQL no problem.

  • 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-11T19:52:51+00:00Added an answer on May 11, 2026 at 7:52 pm

    I ended up brute forcing a solution. It’s not pretty, but since I know the table will be tiny (probably going to end up being only 5 rows) I came up with the following code solution:

    public IList<Waiver> GetLatest()
    {
        using (var session = SessionManager.OpenSession())
        {               
            var criteria = session.CreateCriteria(typeof (Waiver));
            var waivers = criteria.List<Waiver>();
    
            var nonOverridenWaivers = new List<Waiver>();
    
            foreach(var waiver in waivers)
            {
                bool overrideExists = waivers.Any(w => w.Overrides != null &&
                                                       w.Overrides.Id == waiver.Id);
                if (!overrideExists)
                    nonOverridenWaivers.Add(waiver);
            }
    
            return nonOverridenWaivers;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Should simple JavaBeans that have only simple getters and setters be unit tested?? What
I have a simple webform that will allow unauthenticated users to input their information,
I have a simple 2-column layout with a footer that clears both the right
I have a simple setter method for a property and null is not appropriate
I have simple application, that shows list of many items, where user can display
I have simple code that does a head request for a URL and then
I have simple win service, that executes few tasks periodically. How should I pass
I have simple HQL query: var list = OpenSession() .CreateQuery(SELECT MAX(p.price) as max_price, COUNT(p.id)
I have simple method in C# : public static string BetweenOf(string ActualStr, string StrFirst,
I have simple form set up like the following: <form> <input type=text name=first_number id=first_number

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.