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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:48:29+00:00 2026-06-14T07:48:29+00:00

I have two classes from example using Fluent NHibernate mapping. Fluent NHibernate mapping is

  • 0

I have two classes from example using Fluent NHibernate mapping. Fluent NHibernate mapping is commented and I´m trying to make Code Based Mapping, but still appears ArgumentNullException “Value cannot be null.”. How to make it right?

//Fluent NHIbernate mapping for table LocalizationEntry
//public class LocalizationEntryMapping : ClassMap<LocalizationEntry>
//{
//    public LocalizationEntryMapping()
//    {
//        Cache.ReadWrite();
//        CompositeId()
//            .ComponentCompositeIdentifier(x => x.Id)
//            .KeyProperty(x => x.Id.Culture)
//            .KeyProperty(x => x.Id.EntityId)
//            .KeyProperty(x => x.Id.Property)
//            .KeyProperty(x => x.Id.Type);
//        Map(x => x.Message);
//    }
//}
public class LocalizationEntryId
{
    public virtual string Culture { get; set; }
    public virtual string Type { get; set; }
    public virtual string Property { get; set; }
    public virtual string EntityId { get; set; }

    public override bool Equals(object obj)
    {
        if (obj != null)
        {
            LocalizationEntryId other = obj as LocalizationEntryId;
            if (other != null)
            {
                return this.Type      == other.Type &&
                        this.Property == other.Property &&
                        this.EntityId == other.EntityId &&
                        this.Culture  == other.Culture;
            }
        }
        return false;
    }

    public override int GetHashCode()
    {
        return base.GetHashCode();
    }
}

public class LocalizationEntry : IDomainMapper
{
    public virtual LocalizationEntryId Id { get; set; }
    public virtual string Message { get; set; }

    public virtual void Map(ModelMapper mapper)
    {
        mapper.Class<LocalizationEntry>(m =>
        {                
            m.ComposedId( t =>
            {
                t.Property(g => g.Id.Culture, c =>
                {
                    c.NotNullable(true);
                    c.Length(10);
                });
                t.Property(g => g.Id.EntityId, c =>
                {
                    c.NotNullable(true);
                });
                t.Property(g => g.Id.Property, c =>
                {
                    c.NotNullable(true);
                    c.Length(100);
                });
                t.Property(g => g.Id.Type, c =>
                {
                    c.NotNullable(true);
                    c.Length(100);
                });
            });

            m.Property(t => t.Message, c =>
            {
                c.NotNullable(true);
                c.Length(400);
            });
        });
    }
}

//////////// EDIT ////////////////
I found the solution already. Mapping should be done this way:

public virtual void Map(ModelMapper mapper)
        {
            mapper.Class<LocalizationEntry>(m =>
            {
                m.ComponentAsId(x => x.Id, n =>
                {
                    n.Property(x => x.Culture);
                    n.Property(x => x.EntityId);
                    n.Property(x => x.Property);
                    n.Property(x => x.Type);
                });

                m.Property(t => t.Message, c =>
                {
                    c.NotNullable(true);
                    c.Length(400);
                });
            });
        }
  • 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-14T07:48:30+00:00Added an answer on June 14, 2026 at 7:48 am

    I found the solution already. Mapping should be done this way:

    public virtual void Map(ModelMapper mapper)
        {
            mapper.Class<LocalizationEntry>(m =>
            {
                m.ComponentAsId(x => x.Id, n =>
                {
                    n.Property(x => x.Culture);
                    n.Property(x => x.EntityId);
                    n.Property(x => x.Property);
                    n.Property(x => x.Type);
                });
    
                m.Property(t => t.Message, c =>
                {
                    c.NotNullable(true);
                    c.Length(400);
                });
            });
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes one of which inherits from the other. Im trying to
I have two classes (MVC view model) which inherits from one abstract base class.
I have two classes generated by LINQ2SQL both from the same table so they
I have two classes A and B generated by cxf-codegen-plugin from my WSDL. A
I have two classes, one that inherits from the other. The base class is
I have two classes, Item and SoldItem . SoldItem inherits from Item adding some
So, I have two classes, class A and class B. From class A, when
I have two view controller classes in my application delegate. I can change from
I have the following two classes, one inherits from the other Class A{ void
I have a bas class called Media with two classes that inherit from it,

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.