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

  • Home
  • SEARCH
  • 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 282007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:15:07+00:00 2026-05-12T05:15:07+00:00

I like the pattern I saw in this blog post ( http://marekblotny.blogspot.com/2009/04/conventions-after-rewrite.html ), where

  • 0

I like the pattern I saw in this blog post (http://marekblotny.blogspot.com/2009/04/conventions-after-rewrite.html), where the author is checking to see if a table name alteration has already been made before applying a convention.

public bool Accept(IClassMap target)
{
    //apply this convention if table wasn't specified with WithTable(..) method
    return string.IsNullOrEmpty(target.TableName);
}

The convention interface I’m using for a string length is IProperty:

public class DefaultStringLengthConvention: IPropertyConvention
{
    public bool Accept(IProperty property) {
        //apply if the string length hasn't been already been specified
        return ??; <------ ??
    }

    public void Apply(IProperty property) {
        property.WithLengthOf(50);
    }
}

I don’t see where IProperty exposes anything that tells me if the property has already been set. Is this possible?

TIA,
Berryl

  • 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-12T05:15:08+00:00Added an answer on May 12, 2026 at 5:15 am

    To clarify in code what Stuart and Jamie are saying, here’s what works:

    public class UserMap : IAutoMappingOverride<User>
    {
        public void Override(AutoMap<User> mapping) {
            ...
            const int emailStringLength = 30;
            mapping.Map(x => x.Email)
                .WithLengthOf(emailStringLength)                        // actually set it
                .SetAttribute("length", emailStringLength.ToString());  // flag it is set
            ...
    
        }
    }
    
    public class DefaultStringLengthConvention: IPropertyConvention
    {
        public bool Accept(IProperty property) {
            return true;
        }
    
        public void Apply(IProperty property) {
            // only for strings
            if (!property.PropertyType.Equals(typeof(string))) return;
    
            // only if not already set
            if (property.HasAttribute("length")) return;
    
            property.WithLengthOf(50);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the facade-like pattern described here: http://django-tastypie.readthedocs.org/en/latest/non_orm_data_sources.html def obj_get(self, request=None, **kwargs): rv
I was reading this link http://addyosmani.com/largescalejavascript/#modpattern And saw the following example. var basketModule =
This is what I'm referring to: http://twitter.github.com/bootstrap/components.html#badges Is badge the commonly agreed upon term?
I implemented a Singleton pattern like this: public sealed class MyClass { ... public
I have a timedate string in a round-trip data pattern like this: 2012-07-05T11:30:44.1533815Z .
When I was working with XmlDOM in Asp.Net, there was a pattern like this
In C# it is easy to use RegEx like this string pattern = Version\\(\(\\d+).(\\d+).(\\d+).(\\d+)\\\);
I want to do a functional like pattern match to get the first two
I have pattern like below hi hello hallo greetings salutations no more hello for
Watching few examples that use repository pattern like StoreFront I couldn't figure out where

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.