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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:39:41+00:00 2026-05-13T17:39:41+00:00

How can a domain object include a property that calculates a value from other

  • 0

How can a domain object include a property that calculates a value from other database mapped properties so that the calculated property can be used in both the domain object instance and the db level by nhibernate.linq.

I would like to be able to use the property when working with the object directly:

Console.WriteLine(Entity.Calculated.ToString());

And when working with nhibernate.linq

var q = from e in session.Linq<Entity>()
                where e.Calculated > 0
                select e;
  • 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-13T17:39:41+00:00Added an answer on May 13, 2026 at 5:39 pm

    You need to duplicate the logic in the class and the mapping. Here’s an example:

    Class:

    public class Invoice
    {
        public virtual int Id { get; protected set; }
        public virtual decimal Amount { get; set; }
        public virtual decimal Paid { get; set; }
        public virtual decimal Balance
        {
            get { return Amount - Paid; }
        }
    }
    

    Mapping:

    <class name="Invoice">
        <id name="Id">
            <generator class="hilo"/>
        </id>
        <property name="Amount"/>
        <property name="Paid"/>
        <property name="Balance" formula="Amount - Paid" access="readonly"/>
    </class>
    

    Now you can use Linq and query on Invoice.Balance

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

Sidebar

Related Questions

How can my app get a valid last time connected to domain timestamp from
Can two domain objects show on the same page, when the list method is
I'm working on a system were a user can edit existing objects (Filter domain
Can someone point me to a public domain (or MIT- or BSD-license) library for
Can a cookie be shared between two sites on the same top level domain?
I know you can do redirection based on the domain or path to rewrite
I have a domain class containing a couple of fields. I can access them
How do I open 'cross-domain security', so the JavaScript on the page can freely
I understand how I can change the dns settings for my domains by editing
I need to share SSO information between two different domains with a cookie, can

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.