Closed nhibernate-bot closed 6 years ago
I can remember this matter of some years ago and it was a hard work to know which is the property related to each parameter to then set the right parameter type with its size. sig
The situation is even worse since the parameter size is no set even using
var q = session.CreateQuery("from Marca m where m.NickName = :pNickName")
.SetParameter("pNickName", nickname, nickNameQueryType)
.SetReadOnly(true);
with
private static readonly NullableType nickNameQueryType = TypeFactory.GetAnsiStringType(50);
produces this query
NHibernate:
select
marca0_.MarcaID as Marca1_18_,
marca0_.Nombre as Nombr2_18_,
marca0_.NickName as NickN3_18_,
marca0_.Nuevo as Nuevo4_18_,
marca0_.Borrado as Borra5_18_,
marca0_.NombrePlanFinanciacion as Nombr6_18_,
marca0_.PaisID as PaisI7_18_,
marca0_.CertificadoUsadosID as Certi8_18_,
marca0_.Copete as Copet9_18_
from
RT_Marcas marca0_
where
marca0_.NickName=@p0;
@p0 = 'fiat' [Type: AnsiString (8000:0:0)]
Well... just because was disabled de final part, the fix, for those who don't care about use LIKE with a string length as the length of the field, the solution is pretty simple:
public class BackToTheFutureSqlClientDriver: Sql2008ClientDriver
{
protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType)
{
base.InitializeParameter(dbParam, name, sqlType);
if (sqlType.LengthDefined && !IsText(dbParam, sqlType) && !IsBlob(dbParam, sqlType))
{
dbParam.Size = sqlType.Length;
}
if (sqlType.PrecisionDefined)
{
dbParam.Precision = sqlType.Precision;
dbParam.Scale = sqlType.Scale;
}
}
}
Hi, the same issue occurs in EnumCharType
I think be great put this solution in EnumCharType too.
Sorry my english is bad. Thanks
Can you open a new issue for EnumCharType
? Or directly a PR with tests if you can contribute your fix.
About EnumAnsiCharType
, it would have to be done as a separated issue or PR, since that is a new feature.
Carlos Bustos created an issue — :