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="Mapping开发者_如何学JAVAClasses" 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?
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.
精彩评论