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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:23:41+00:00 2026-05-18T07:23:41+00:00

I have a database with a field ‘LS_GENDER’ which stores genders as ‘M’ or

  • 0

I have a database with a field ‘LS_GENDER’ which stores genders as ‘M’ or ‘F’.

My application uses an enumeration called Gender to work with genders.

My entity has the following field and property:

private string _gender;

public Gender Gender { get { return GetGenderFromString(_gender); } };

private Gender GetGenderFromString(string strGender)
{
  switch (strGender.ToLower())
  {
    case "f":
      return Gender.Female;
    case "m":
      return Gender.Male;
    default:
      return Gender.Unknown;
  }
}

How do I map this with FluentNHibernate? I am trying to use field access (as shown below):

Map(x => x.Gender).Column("LS_GENDER").Access.CamelCaseField(Prefix.Underscore);

but I’m getting the error ‘Can’t parse F as Gender’. I think NHibernate is getting confused because the property and field are not of the same type.

How should I map this?

  • 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-18T07:23:41+00:00Added an answer on May 18, 2026 at 7:23 am

    You map a private field using reveal:

    Map(Reveal.Member<ClassType>("_gender")).Column("LS_GENDER");
    

    But that doesn’t resolve your LINQ problem because now NHibernate doesn’t know about the Gender property. To resolve both issues I would use a custom user type that implements IUserType.

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

Sidebar

Related Questions

I have in database the field called Profit. In my application I calculating profit:
I have a variable called $tags , which just references from a database field.
At the moment I have a database field which stores passwords like this: TeacherPassword
I have a database which has a NOT NULL constraint on a field, and
in my database we have a field which is going beyond int max value,
Okay so I have a database field called moderated It is an ENUM with
I have a number mysql database field named numbers in which there are 10
I had a database field which stores passwords like this: TeacherPassword j.lu01 pesci02 cricket01
I have a database field called abCode , that I want to map to
I have a database table which records all field changes in all database tables

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.