Check for existing mapping when writing a custom applier in ConfORM

Posted by Philip Fourie on Stack Overflow See other posts from Stack Overflow or by Philip Fourie
Published on 2012-11-22T10:57:40Z Indexed on 2012/11/22 10:59 UTC
Read the original article Hit count: 130

Filed under:
|

I am writing my first custom column name applier for ConfORM.

How do I check if another column has already been map with same mapping name?

This is what I have so far:

public class MyColumnNameApplier : IPatternApplier<PropertyPath, IPropertyMapper>
{
    public bool Match(PropertyPath subject)
        {
            return (subject.LocalMember != null);
        }

        public void Apply(PropertyPath subject, IPropertyMapper applyTo)
        {
            string shortColumnName = ToOracleName(subject);
            // How do I check if the short columnName already exist?
            applyTo.Column(cm => cm.Name(shortColumnName));
        }

        private string ToOracleName(PropertyPath subject)
        {
            ...
        }
    }
}

I need to shorten my class property names to less than 30 characters to fit in with Oracle's 30 character limit. Because I am shortening the column names it is possible that I generate the same name for two different properties. I would like to know when a duplicate mapping occurs.

If I don't handle this scenario ConfORM/NHibernate allows two different properties to 'share' the same column name - this is obviously creates a problem for me.

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about ConfORM