Reputation: 2497
I have table columns with table number suffix
create table T1234_DATA (CHANGEUSER_1234 nvarchar(50), ...)
For tables I wrote fluent mapping. When used directly it works fine, but there are (for some historical reason) many views or stored procedures which are aliasing columns to generic suffic _0001
:
create view v1234_DATA as select CHANGEUSER_1234 as CHANGEUSER_0001
Whenever I want to use such view I have to write full class mapping again. Is there some sort of alternative column mapping in Fluent or HBM to share it between all named queries? Wildcards in sql column names, selecting alternative class mapping on the query, multiple sql columns mapped to single property, etc.?
Upvotes: 0
Views: 554
Reputation: 96
If I understood your question, a Join could solve the problem.
As you can see in:
NHibernate Mapping - <join/>
How to join table in fluent nhibernate
Or maybe you could use a formula (or some formulas) like:
public class UserMap : ClassMap<User> {
public User() {
Table("TB_USER");
Id(x => x.Id).GeneratedBy.Identity();
Map(x => x.ChangeUser1234, "CHANGEUSER_1234");
Map(x => x.ChangeUser0001)
.Formula("(select CHANGEUSER_0001 from TABLE where ...)");
}
}
Upvotes: 1