I have a particular case where I need to define a query including a table ASpecialTable
for which I don't have any mapping or business class defined.
However, the return type of the query is an existing business class MyBO
.
For that particular table, I'll never need it in my code, and it doesn't contain a primary key, or to be short: I won't be willing/able to create a class for it.
So the only way I know of would be to define a SQLQuery
of the kind:
session.CreateSQLQuery("select MyBO.* from MyBO ... ASpecialTable ... where ...")
.AddEntity(typeof(MyBO)).List<MyBO>();
The problem with this is that I have to tightly couple my code to the database layout. It's not encapsulated in the mapping files anymore. I have to do that even for MyBO for which a mapping exists. The mapping logic is encoded redundantly in the mapping file as well as in the code parts that contain these queries (even if I'd use named queries and have the query strings in the config file, the redundancy is still there).
Is it possible to define a mapping for ASpecialTable
without an <id>
and without a corresponding class in the code?