-
Notifications
You must be signed in to change notification settings - Fork 936
Open
Description
NHibernate nuget v5.2.1
hibernate.config:
<?xml version="1.0" encoding="UTF-8"?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.connection_string">server=127.0.0.1;port=5432;database=aspnet_core_app;user id=postgres;password=***;</property>
<property name="dialect">NHibernate.Dialect.PostgreSQL83Dialect</property>
<property name="connection.driver_class">NHibernate.Extensions.NpgSql.NpgSqlDriver,NHibernate.Extensions.NpgSql</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="adonet.batch_size">10</property>
<mapping assembly="WebTest" />
</session-factory>
</hibernate-configuration>
I use NHibernate.AspNetCore.Identity will have the following problems.(I believe that it also exists in NHibernate.AspNet.Identity)
Sample linq code:
var admin = manager.Users.
Where(x => x.UserName.ToUpper() == "admin".ToUpper()).
Select(x => x.UserName).FirstOrDefault();
Intercepted sql statement:
select
applicatio0_1_.user_name as col_0_0_
from
public.application_users applicatio0_
inner join
public.aspnet_users applicatio0_1_
on applicatio0_.id=applicatio0_1_.Id
where
upper(applicatio0_1_.user_name)='ADMIN' limit 1;
Can query the information of the user admin, so far so good. When I change the current thread culture.
Still the same linq code:
Thread.CurrentThread.CurrentCulture = new CultureInfo("tr");
var admin2 = manager.Users.
Where(x => x.UserName.ToUpper() == "admin".ToUpper()).
Select(x => x.UserName).FirstOrDefault();
Intercepted sql statement:
select
applicatio0_1_.user_name as col_0_0_
from
public.application_users applicatio0_
inner join
public.aspnet_users applicatio0_1_
on applicatio0_.id=applicatio0_1_.Id
where
upper(applicatio0_1_.user_name)='ADMİN' limit 1;
In the current culture, the uppercase of admin
is no longer ADMIN but ADMİN
ADMİN ≠ ADMIN
Can't find any user information.
I think the linq method should be translated into something like the following(The method of the parameter is also translated into a database function. by the way: EF will do this):
select
applicatio0_1_.user_name as col_0_0_
from
public.application_users applicatio0_
inner join
public.aspnet_users applicatio0_1_
on applicatio0_.id=applicatio0_1_.Id
where
upper(applicatio0_1_.user_name)=upper('admin') limit 1;
upper(applicatio0_1_.user_name)=upper('admin')
Metadata
Metadata
Assignees
Labels
No labels