views:

44

answers:

1

Is it possible to set a naming convention for all collection of an entity even if I use the Access Strategy or not, so that all collection names are {EnityName}s instead of {entityName}s (because of Access.CamelCaseField(Prefix.Underscore) the first letter is lower)?

Or is there a way where I can tell NHibernate that it shall use the associationPath case insensitive in the SetFetchMode method?

This method is not case insensitive:

ICriteria SetFetchMode(string associationPath, FetchMode mode)

I try to build a type safe way of setting the associationPath

EDIT:

The associationPath is the name attribute of the collection.

<set access="field.camelcase-underscore" cascade="save-update" inverse="true" lazy="true" name="employees" table="TeamEmployee" mutable="true">

I want to define a naming convention for the name attribute.

EDIT:

I found something like this:

public class LowercaseCollectionNameConvention : IClassConvention
{
    public void Apply(IClassInstance instance)
    {
        instance.Collections. ...
    }
}

Does someone one know how to use this?

A: 

I am not sure I fully understand the context of your question. If you are after a naming strategy for the relationship during mapping and schema generation then you need to do some sort of "Convention".

I recently blogged my conventions http://blog.zoolutions.se/post/2010/07/03/Inflector-e28093-renaming-utilities.aspx and http://blog.zoolutions.se/post/2010/07/05/All-my-current-Fluent-NHibernate-Conventions.aspx

If you could add some better description I'll be happy to extend my answer.

EDIT The following should get you pretty close if you copy the Inflektor class from my blog or any other location it can be found:

public class HasManyConvention : IHasManyConvention
{
    public void Apply(IOneToManyCollectionInstance instance)
    {
        instance.Cascade.SaveUpdate();
        instance.Inverse();
        string pluralized = Inflector.Pluralize(instance.ChildType.Name);
        instance.Name(pluralized.ToLower());
    }
}
mhenrixon
is your code for defining a naming convention for the name of the collection of the hbmxml file? <set access="field.camelcase-underscore" cascade="save-update" inverse="true" lazy="true" name="employees" table="TeamEmployee" mutable="true"> I want a convention for the name attribute.
Rookian
I edited my question ... =)
Rookian