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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:00:44+00:00 2026-06-12T09:00:44+00:00

If I don’t map Color but map an object that has a Color attribute,

  • 0

If I don’t map Color but map an object that has a Color attribute, FluentNHibernate successfully maps it to a varbinary(max). However, that’s extremely inefficient given that realistically Color is just composed of 4 bytes and I am keen on improving it without using a new type to Proxy it.

Internally within Color it is made up of four properties,

  1. long value (cast down to int to represent ARGB)
  2. short state, indicates if this is a known & valid colour
  3. string name, the name of the colour if known.
  4. short knownColor a value to indicate which known colour it is

So I have attempted to map this as follows.

public ColorMapping()
{
    CompositeId()
        .KeyProperty(c => Reveal.Member<Color, long>("value"))
        .KeyProperty(c => Reveal.Member<Color, short>("state"))
        .KeyProperty(c => Reveal.Member<Color, string>("name"))
        .KeyProperty(c => Reveal.Member<Color, short>("knownColor"));
}

However, on usage I get the following exception,

Class Initialization method DataContextTest.ClassInitialise threw
exception. FluentNHibernate.Cfg.FluentConfigurationException:
FluentNHibernate.Cfg.FluentConfigurationException: An invalid or
incomplete configuration was used while creating a SessionFactory.
Check PotentialReasons collection, and InnerException for more detail.

—> FluentNHibernate.Cfg.FluentConfigurationException: An invalid or
incomplete configuration was used while creating a SessionFactory.
Check PotentialReasons collection, and InnerException for more detail.

—> NHibernate.MappingException: Could not compile the mapping
document: (XmlDocument) —> NHibernate.MappingException: Could not
determine type for:
System.Linq.Expressions.Expression1[[System.Func2[[System.Drawing.Color,
System.Drawing, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a],[System.Int64, mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]],
mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089]], System.Core, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089, for columns:
NHibernate.Mapping.Column(Member).

Am I misusing Reveal? If so, how am I meant to use it?

  • 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-12T09:00:46+00:00Added an answer on June 12, 2026 at 9:00 am

    i would map it as UserType which converts it back and forth

    // in mapping
    Map(x => x.Color).Column("ColorARGB").CustomType<ColorUserType>();
    
    [Serializable]
    class ColorUserType : IUserType
    {
        public object Assemble(object cached, object owner)
        {
            return DeepCopy(cached);
        }
    
        public object DeepCopy(object value)
        {
            return value;
        }
    
        public object Disassemble(object value)
        {
            return DeepCopy(value);
        }
    
        bool IUserType.Equals(object x, object y)
        {
            var colorX = x as Color;
            var colorY = y as Color;
            return colorX == null ? colorY = null : colorX.ToArgb() == colorY.ToArgb();
        }
    
        public virtual int GetHashCode(object x)
        {
            var colorX = (Color)x;
            return (colorX != null) ? colorX.ToArgb() : 0;
        }
    
        public bool IsMutable { get { return false; } }
    
        public object NullSafeGet(IDataReader rs, string[] names, object owner)
        {
            return Color.FromArgb((int)NHibernateUtil.Int32.Get(rs, names[0]));
        }
    
        public void NullSafeSet(IDbCommand cmd, object value, int index)
        {
            NHibernateUtil.Int32.Set(cmd, ((Color)value).ToArgb(), index);
        }
    
        public object Replace(object original, object target, object owner)
        {
            return original;
        }
    
        public Type ReturnedType { get { return typeof(Color); } }
    
        public SqlType[] SqlTypes { get { return new []{ SqlTypeFactory.Int32 }; } }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

DON'T ASK WHY but... I have a regex that needs to be case insensitive
Don't ask questions, but basically my game has a lot of mouse cursors chasing
don't know if the title describes anything about what I'm trying to say but
Don't ask me how but I'm in a situation where I have DCPs published
Don't really know how to formulate the title, but it should be pretty obvious
Don't know how to google for such, but is there a way to query
Don't know why but font is not displaying.Please help. CSS(in css folder): style.css: @font-face
Don't ask me why but I need to do the following: string ClassName =
I don't know why, but this code worked for me a month ago... maybe
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.