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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:54:58+00:00 2026-05-23T04:54:58+00:00

C# 3.0, Nhibernate 2.1.2 , Castle ActiveRecord 2.1, WinXP 32 I have a problem

  • 0

C# 3.0, Nhibernate 2.1.2 , Castle ActiveRecord 2.1, WinXP 32

I have a problem filtering elements with ActiveRecord and DetachedCriteria.
There are 2 tables one contains the objects to be filtered (PropertyContainer) and the other contains the values of dymamic property set for this object (PropertyValue).

PropertyContainer
 Id int

PropertyValue
 Id             int
 ContainerId    int
 Value          real

I need to select PropertyContainer object with the values from PropertyValue table matching some condition (e.g. property with Id = 1 and Value > 2). I would like to do this using DetachedCriteria, I am trying to write something like this:

var detachedCriteria = DetachedCriteria.For(typeof(PropertyContainer));

detachedCriteria.SetProjection(
    Projections.SqlProjection(@"select Value from PropertyValue where Id=1"),
    new[] { "ExternalProperty" }, 
    new[] { NHibernateUtil.Double }));  

detachedCriteria.Add(Expression.Ge("ExternalProperty",2));

var filteredItems = PropertyContainer.SlicedFindAll(0,100,detachedCriteria);

Then this call is executed I get the following error:
“could not resolve property: ExternalProperty of: PropertyContainer”

The question is:

  1. What is wrong with this approach ?
  2. What is the right way to do filtration by dynamic property set using ActiveRecord/NHibernate and DetachedCriteria ?
  • 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-23T04:54:59+00:00Added an answer on May 23, 2026 at 4:54 am

    if PropertyValue looks like:

    class PropertyValue
    {
        public virtual int Id { get; set; }
        public virtual double Value { get; set; }
    }
    

    you can do:

    DetachedCriteria.For<PropertyContainer>()
        .CreateAlias("PropertyValues", "prop")
        .Add(Restrictions.Ge("prop.Value", 2))
        .Add(Restrictions.Eq("prop.Id", 1));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Castle ActiveRecord / NHibernate: Is there a way you can force an ICriterion
I have an open Castle ActiveRecord SessionScope. I need to use the nhibernate session
Assume you are using some libraries like NHibernate or Castle ActiveRecord that use log4net
Does Castle ActiveRecord supports SQL formula as supported by nHibernate? E.g. In nHibernate we
I'm using ASP.Net MVC (still 1.0 for now) with Castle ActiveRecord and NHibernate.Linq. All
Is Castle ActiveRecord's SessionScope exact equivalent of NHibernate's ISession? If yes, why Castle ActiveRecord
Has anyone gotten Fluent NHibernate to work with Castle ActiveRecord? I am particularly interested
I am playing with Castle activeRecord, and I have succesfully made an asp.net MVC
Is there a way in Castle Active Record/NHibernate to join across two databases? I
I have intergrated nHibernate search, with my nhibernate/ActiveRecord project. I am trying to get

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.