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

  • Home
  • SEARCH
  • 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 650037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:00:34+00:00 2026-05-13T22:00:34+00:00

I’m using Fluent NHibernate, and auto-mapping the classes. I have a computed property in

  • 0

I’m using Fluent NHibernate, and auto-mapping the classes.

I have a computed property in a class along the lines of

public virtual DateTime? LastActionTimeStamp
{
    get {
        return Actions.Count == 0 ? null : Actions.OrderByDescending(
            a => a.TimeStamp).ElementAt(0).TimeStamp;
    }
}

This wasn’t mapped with the rest of the properties, so I couldn’t use it in an ICriteria restriction. I added an empty setter (as I read somewhere that doing so would include it in the mapping, which it does), but now I’m getting an NHibernate error:

could not execute query … Invalid column name ‘LastActionTimeStamp’.

So my question is: how do I tell Fluent NHibernate to tell NHibernate to ignore the database for this property, but still return the calculated value from the property get?

  • 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-13T22:00:34+00:00Added an answer on May 13, 2026 at 10:00 pm

    You could associate a formula with the property and use that instead of the c# code. e.g.

    Property:

    private int _postCount = 0;
    public virtual int PostCount
    {
        get
        {
            return _postCount;
        }
    }
    

    Formula:

    (SELECT count(p.ID) FROM BlogPost p WHERE p.BlogID = ID and p.IsDeleted = 0)
    

    And then you can use PostCount in your expression as usual. Remember to set the access modifier on the property in your FluentMapping. Not sure what Fluent supports but the options I have found for normal mapping are:

    * property
    * field
    * field.camelcase
    * field.camelcase-underscore
    * field.pascalcase-m-underscore
    * field.lowercase-underscore
    * nosetter.camelcase
    * nosetter.camelcase-underscore
    * nosetter.pascalcase-m-underscore
    * nosetter.lowercase-underscore
    

    Probably best check out NHibernate documentation for the official list Access Strategies so you combine the access strategy with the naming strategy e.g. “field.lowercase-underscore”

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

Sidebar

Related Questions

No related questions found

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.