Bonjour,
J'ai besoin de faire une requete SQL native pour des raisons de temps de réponsse (Nhibernate me fait des requetes qui donne 2 millions d'opération)
Mais voila, ma requete SQL native ne passe pas et me renvoie cette exception:
ERROR NHibernate.ADOException error in FindBySQL
System.IndexOutOfRangeException: Id0_
Voici le code de mon appli
Code :
- //query nhibernate
- int release;
- release = (int) a_type;
- string sql_str = "SELECT distinct QIdxConstituent.* FROM dbo.QIdxConstituent QIdxConstituent ";
- sql_str += "INNER JOIN dbo.QIdxComposition qidxcomposition ON QIdxConstituent.CompositionId = qidxcomposition.Id , dbo.QIdxIndex qIdxIndex ";
- sql_str += "WHERE (qidxcomposition.ReleaseDate ='" + a_date.Month +"/"+ a_date.Day +"/"+ a_date.Year + "') or ( (qidxcomposition.ReleaseDate ='" + a_date.Month +"/"+ a_date.Day +"/"+ a_date.Year + "') ";
- sql_str += "AND (qidxcomposition.ReleaseType =" + release + " ) AND (qidxcomposition.IndexTicker ='" + a_indexIdentifier + "') ";
- sql_str += "AND (qIdxIndex.Ticker = qidxcomposition.IndexTicker) AND (qIdxIndex.RIC = qidxcomposition.IndexTicker))";
- IQuery l_query = a_hibernator.CreateSQLQuery( sql_str, "QIdxConstituent", typeof(QIdxConstituent));
- IList l_hqlResult = l_query.List();
- return l_hqlResult;
|
La requete original =
SELECT distinct qidxconstituent.Id AS Id, qidxconstituent.CompositionId AS CompositionId, qidxconstituent.InstrumentId AS InstrumentId, qidxconstituent.Weight AS Weight FROM dbo.QIdxConstituent qidxconstituent INNER JOIN dbo.QIdxComposition qidxcompos1_ ON qidxconstituent.CompositionId = qidxcompos1_.Id , dbo.QIdxIndex qidxindex2_ WHERE (qidxcompos1_.ReleaseDate ='1/3/2030') or ( (qidxcompos1_.ReleaseDate ='1/3/2030') AND (qidxcompos1_.ReleaseType =0) AND (qidxcompos1_.IndexTicker ='MMMM999999') AND (qidxindex2_.Ticker = qidxcompos1_.IndexTicker) AND (qidxindex2_.RIC = qidxcompos1_.IndexTicker))
Merci