Fluent NHibernate different Conventions for different base types -


at moment keeping entities , mappings same assembly. our entities derived basic class entity entitywithtypedid

also having table name convention telling pluralize table names.

now want create other 2 base types e.q. aggregaterootentity , aggregateentity, both derive entity. , create 2 set of conventions both base entities:

let's say: for entities derived aggregaterootentity tables should prefixed "ag_" , id incremental generated, entities derived aggregateentity tables should prefixed "a_" , ids should assigned.

is possible set conventions based on conditions?

you can multiple conventions, each checking specific type in accept methods

something like:

public class legacyentitytableconvention : iclassconvention, iclassconventionacceptance {   public void accept(iacceptancecriteria<iclassinspector> criteria)   {     criteria.expect(x => x.entitytype.isany(typeof(oldclass), typeof(anotheroldclass)));   }    public void apply(iclassinstance instance)   {     instance.table("tbl_" + instance.entitytype.name);   } } 

just block of code out of fnh wiki http://wiki.fluentnhibernate.org/acceptance_criteria


Comments

Popular posts from this blog

silverlight - Applying a style to ItemContainerStyle in C# -

c# - NullReferenceException in MySqlClient.NativeDriver -

php - Updating recent updates - Problem in procedure - Any other approach? -