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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:24:22+00:00 2026-06-11T03:24:22+00:00

Background : I am connecting to a legacy Database that has two entities: Order

  • 0

Background: I am connecting to a legacy Database that has two entities:

Order (Id, Date, ...)    

ForwardOrder(OrderId)

… as you can see ForwardOrder could be just a property of an Order

Requirements: Try to reflect ForwardOrder as a Boolean property of Order class in .NET. Connect to the database with NHibernate.

The problem: I tried implementing IUserType but no luck – column doesn’t exist error.

The mapping is Map(x=>x.IsForwardOrder).CustomType<ForwardOrderType>();

Adding a Formula does make it load properly, but the IUserType setter is never used.

Question: Can it be done? Can an object’s existence in a separate table be a flag on my Entity? I know that I can just map a related object but I would rather to avoid that.

  • 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-06-11T03:24:24+00:00Added an answer on June 11, 2026 at 3:24 am

    The way to do this is set up the ForwardOrder as a protected property on the code level and treat it like a lazy component. Then you can actually leave IsForwardOrder out of your NHibernate mapping completely and just do something like:

      public bool IsForwardOrder { get { return ReferenceEquals(this.ForwardOrder,null); } }
    

    You could use polymorphism as well, but it seems like overkill for a boolean. This approach would entail creating a subclass that has the ForwardOrder property and defining a table-per-subclass join to the ForwardOrder table. You would still need to define a boolean property like

      public virtual bool IsForwardOrder { get { return false; } }
    

    on the base class

      public override bool IsForwardOrder { get { return true; } }
    

    on the joined subclass.

    Alternatively, with this approach, you could use an extension method such as

     public static bool IsForwardOrder(this Order order) { return order is ForwardOrder; }
    

    (assuming the base class is Order and the subclass is ForwardOrder)

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

Sidebar

Related Questions

In an organization that has two applications each with its own Oracle database instance,
Background School Corp. has two databases with a common table, employees. These two databases
Folks: Has anyone had success connecting to a Progress-4GL database with Delphi ?  
Background I have a service that is connecting to Microsoft CRM 2011, and updating
Background I'm new to spring MVC but I can clearly see the benefit of
Background: I've been tasked with converting an Access database application to ASP.Net C# MVC.
Background: We're building an application that allows our customers to supply data in a
Background: I would like to dismiss a modalView that I have presented earlier and
I'm trying to create a simple visual basic 6 program/database that uses ms access
Background : I have built a tool that imports sales orders from Magento to

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.