c# - Nhibernate: Multiple classmaps for one entityclass -
so, i'm writing reusable library. , nhibernate mapping code used orm operations. there multiple services making use of library want library behave dynamically possible.
there multiple services , every service there specific tables found in database, these prefixed service name. unity inject prefix , works nice , dandy when using 1 service.
but i'm @ point have write service read , combine multiple services. libdummy item have mapped multiple times different table prefixes.
public class libdummy { public virtual int id { get; set; } public virtual string guid { get; set; } } public class libdummymapping : classmapping<libdummy> { public libdummymapping(servicename service) { table($"{service.name}_libdummy"); id(o => o.id, m => m.column("id")); property(o => o.guid, m => m.column("guid")); } }
i tried doing this:
public class firstlibdummymapping : libdummymapping { public firstlibdummymapping (servicename service) : base(service) { } } public class secondlibdummymapping : libdummymapping { public secondlibdummymapping (servicename service) : base(service) { } }
but throw "duplicate class/entity mapping" error. , 2 different classmaps same entity throw collection mapped error.
ideally have 1 dynamic classmap can natively used in library, that's not option guess??
any ideas this, or not going work?
any nhibernate guru's definitive answer?
Comments
Post a Comment