Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NHibernate inconsistent sql column alias

When looking at our queries from NHibernate it's clear that the column alias is not consistent, that a problem for performance when the sql server execution plan seeing the same query as different query's because of the inconsistent column alias.

An example could be something like this:

SELECT this_.Id as Id44_0_ FROM dbo.[Foos] this_

SELECT this_.Id as Id43_0_ FROM dbo.[Foos] this_

Is there any way we can make consistent column alias?

We are using Fluent NHibernate with Auto mapping

like image 430
Lehto Avatar asked Feb 20 '12 09:02

Lehto


1 Answers

Optionally by setting projection you can get a custom name as an alias in the query as follows

Projections.Property("candidate.Name"), "CandidateName");

How to use NHibernate Projections to retrieve a collection

like image 123
Anand Avatar answered Oct 12 '22 20:10

Anand