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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:39:11+00:00 2026-05-16T10:39:11+00:00

I am starting a simple .NET project with FluentNhibernate . I’ve followed few examples

  • 0

I am starting a simple .NET project with FluentNhibernate.
I’ve followed few examples I’ve found on the Internet and it seems quite easy to grasp.
I’ve realized that if I let FluentNhibernate build my DB schema (Sql Server 2000) it generates NVARCHAR fields for my strings model properties.

Someone suggested that I can add a convention to change the type.

This bit of code works great:

public class AnsiStringConvention : IPropertyConvention 
        {
            private static Type stringType = typeof(string);
            public void Apply(FluentNHibernate.Conventions.Instances.IPropertyInstance instance)
            {
                if (instance.Property.PropertyType == stringType)
                {
                    instance.CustomType("AnsiString");
                }
            }
        }

Now my DB fields are VARCHAR, as I expected.
I needed to add a component to my class, following the DDD pattern I’ve put the Address
in a separate class and added it to my Customer class.
I’ve created a separate mapping file for the address:

public class AddressMap : ComponentMap<Address>
{
    public AddressMap()
    {
        Map(x => x.Number);
        Map(x => x.Street)
            .Length(100);
        Map(x => x.City)
            .Length(50);
        Map(x => x.PostCode)
            .Length(5);
    }
}

Now, all the fields of my Customer table are VARCHAR but the fields of the Address (Street, City and PostCode) component are still created as NVARCHAR.

  • 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-16T10:39:12+00:00Added an answer on May 16, 2026 at 10:39 am

    Found a solution defining AnsiString as CustomType:

    public class AddressMap : ComponentMap<Address>
    {
        public AddressMap()
        {
            // this.Map(x => x.Number);
            this.Map(x => x.Street)
                .CustomType("AnsiString") 
                .Length(100);
            this.Map(x => x.City)
                .CustomType("AnsiString")
                .Length(30);
            this.Map(x => x.State)
                .CustomType("AnsiString")
                .Length(20);
            this.Map(x => x.PostalCode)
                .CustomType("AnsiString")
                .Length(10);
            this.Map(x => x.Country)
                .CustomType("AnsiString")
                .Length(40);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm starting a simple web application, using ASP.Net MVC 3. I made a few
I've been developing a simple website using asp.net MVC and I'm starting to add
I will be starting a simple datastore-and-search project soon. Basically, one of those put
I'm a .Net guy, and I'm interested in starting this project but I'm not
I have been able to develop a simple asp.net project without vs. Can someone
I'm starting a new project which in simple terms will have a UI layer
I'm working on a simple command line project. I changed the properties from .NET
I'm a relatively new hire, and I'm starting on a small, fairly simple project.
I'm starting a new project on .NET 4. All the libraries I'll be creating
Starting with a simple list: <ul> <li>Item 1</li> <li style=display: none;>Item 2</li> <li>Item 3</li>

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.