views:

17

answers:

1

Hi, I have a entity project which holds about 30 classes and this project is used in several web applications. One application maybe uses all the 30 classes but another one only uses 3 classes. So my question is: How can I add just the classes that a uniqe application needs? My first thought was to add the names of the needed classes in app settings in web.config like:

<add key="MappingClasses" value="User,Application,News" />

And then split and loop in the configuration of the session factory. But I really would like your input on this! What is the best approach to achieve this?

A: 

You can tell to your AutoPersistenceModelGenerator to Filter classes by some criteria.

e.q.

    /// <summary>
    /// Provides a filter for only including types which inherit from the IEntityWithTypedId interface.
    /// </summary>
    private bool GetAutoMappingFilter(Type t)
    {
        return t.GetInterfaces().Any(x =>
                                     x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IEntityWithTypedId<>));
    }

So now you could read your config file and using reflection to create your filter criteria.

isuruceanu

related questions