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

I'm trying to prove that changing document.domain can be used only for cross scripting
I have a domain object called User . Properties of user include ssoId, name,
Let us say my domain object can contain a bunch of objects like this:
I'm using HtmlAgilityPack how can I get the domain from the following objects? private
Can one upload files to a domain other than the domain a script originates
I can define default value in domain by this way : class ProcessingPriority {
In my domain I have entities that don't have setters on the properties (except
If I'm rendering a regular view in asp.net mvc the only domain object properties
If my domain object should contain string properties in 2 languages, should I create
I have a basic domain object, say like Person or Campaign or Event that

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.