1
I have an appointment in LINQ and I need to capture the generated sql, but I did not succeed. The conversion to Objectquery that I found does not work. What is missing?
var sqlConsulta = (from a in Sessao.Query<RequisitorioNaoLevantado>()
where (a.Codvara == codigoVara) &&
(string.IsNullOrEmpty(numeroProcesso) ||
a.AcaoOriginaria.Equals(numeroProcesso))
select a);
var sqlGerado = (ObjectQuery)sqlConsulta;
var commandSql = sqlGerado.ToTraceString();
For sqlConsulta.Tostring(), we have:
Nhibernate.Linq.Nhqueryable`1[Model...]
The line (Objectquery)sqlConsult, generates the exception:
"Cannont cast 'sqlConsulta' (which has an actual type of 'NHibernate.Linq.NhQueryable`1[Modelo.Entidades.Esparta.RequisitorioNaoLevantado]' to 'System.Data.Objects.ObjectQuery"
That’s what? Entity Framework?
– Jéf Bueno
The resources used are: Nhibernat + Fluentnhibernate + Linq;
– SantanaFire