Jean Bastos
2018-09-26 14:00:06 UTC
When I do this query:
var query = from entity in session.Query<Entity>()
where entity.Status != 2
select entity;
NHibernate generate this SQL:
SELECT ...
FROM TABLE_NAME ALIAS
WHERE ALIAS.SITFIL <> 2
or ALIAS.SITFIL is null /*this 'or' is the problem*/
Why NHibernate do this?
The 'or' causes a performance issue on my application I want to generate
just:
SELECT ...
FROM TABLE_NAME ALIAS
WHERE ALIAS.SITFIL <> 2
Without 'Or field is null'
The mapping not is nullable:
[Property(Column = "SITFIL")]public virtual TypeEnumOfProperty Status { get; set; }
The enum:
public enum TypeEnumOfProperty{
[Display(Name = "Ativa", Description ="Ativo")]
Ativa = 0,
[Display(Name = "Inativa", Description = "Inativo")]
Inativa = 1,
[Display(Name = "Inativa e oculta", Description = "Inativo e oculto")]
InativaOculta = 2,}
If I change the TypeEnumOfProperty to int the SQL is generated like I want,
if change to TypeEnumOfProperty or long then was generated with the 'or'
Someone knows why and how solve this?
var query = from entity in session.Query<Entity>()
where entity.Status != 2
select entity;
NHibernate generate this SQL:
SELECT ...
FROM TABLE_NAME ALIAS
WHERE ALIAS.SITFIL <> 2
or ALIAS.SITFIL is null /*this 'or' is the problem*/
Why NHibernate do this?
The 'or' causes a performance issue on my application I want to generate
just:
SELECT ...
FROM TABLE_NAME ALIAS
WHERE ALIAS.SITFIL <> 2
Without 'Or field is null'
The mapping not is nullable:
[Property(Column = "SITFIL")]public virtual TypeEnumOfProperty Status { get; set; }
The enum:
public enum TypeEnumOfProperty{
[Display(Name = "Ativa", Description ="Ativo")]
Ativa = 0,
[Display(Name = "Inativa", Description = "Inativo")]
Inativa = 1,
[Display(Name = "Inativa e oculta", Description = "Inativo e oculto")]
InativaOculta = 2,}
If I change the TypeEnumOfProperty to int the SQL is generated like I want,
if change to TypeEnumOfProperty or long then was generated with the 'or'
Someone knows why and how solve this?
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.