Sto cercando di implementare la funzione FREETEXT per Sql Server 2008.

Ho seguito questo esempio:

http://xlib.wordpress.com/2009/12/04/integrating-freetext-search-in-nhibernate-detached-criteria/

La query (da log) viene generata correttamente e lanciata sul db
funziona alla grande.

Se provo ad esegiurla da codice ricevo il seguente errore:

The argument type "nvarchar(max)" is invalid for argument 2 of
"FREETEXT".

LOG:
  SELECT
        TOP (@p0) this_.Id as Id3_0_,
        this_.Corpo as Corpo3_0_,
        this_.Data as Data3_0_,
        this_.DataInserimento as DataInse4_3_0_,
        this_.LinkPagina as LinkPagina3_0_,
        this_.Numero as Numero3_0_,
        this_.Oggetto as Oggetto3_0_,
        this_.ParoleChiavi as ParoleCh8_3_0_,
        this_.SottoTitolo as SottoTit9_3_0_,
        this_.idArticoloOld as idArtic10_3_0_,
        this_.IdUser as IdUser3_0_
    FROM
        Articoli this_
    WHERE
        freetext(this_.Corpo, @p1)
    ORDER BY
        this_.DataInserimento desc;
    SELECT
        count(*) as y0_
    FROM
        Articoli this_
    WHERE
        freetext(this_.Corpo, @p2);
    ;
    @p0 = 10 [Type: Int32 (0)], @p1 = 'sacconi' [Type: String
(1073741823)], @p2 = 'sacconi' [Type: String (1073741823)] 101877ms
2010-12-14 10:17:05,134 (null)   8     ERROR
NHibernate.AdoNet.AbstractBatcher Could not execute query: SELECT TOP
(@p0) this_.Id as Id3_0_, this_.Corpo as Corpo3_0_, this_.Data as
Data3_0_, this_.DataInserimento as DataInse4_3_0_, this_.LinkPagina as
LinkPagina3_0_, this_.Numero as Numero3_0_, this_.Oggetto as
Oggetto3_0_, this_.ParoleChiavi as ParoleCh8_3_0_, this_.SottoTitolo
as SottoTit9_3_0_, this_.idArticoloOld as idArtic10_3_0_, this_.IdUser
as IdUser3_0_ FROM Articoli this_ WHERE freetext(this_.Corpo, @p1)
ORDER BY this_.DataInserimento desc;
SELECT count(*) as y0_ FROM Articoli this_ WHERE freetext(this_.Corpo,
@p2);
 102252ms
System.Data.SqlClient.SqlException: The argument type "nvarchar(max)"
is invalid for argument 2 of "FREETEXT".
   in System.Data.SqlClient.SqlConnection.OnError(SqlException
exception, Boolean breakConnection)
   in System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection)
   in
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj)
   in System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj)
   in System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
   in System.Data.SqlClient.SqlDataReader.get_MetaData()
   in
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,
RunBehavior runBehavior, String resetOptionsString)
   in
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
async)
   in
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, DbAsyncResult result)
   in
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method)
   in System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
behavior, String method)
   in
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior
behavior)
   in
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
   in NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)


E' come se NHibernate cerca il campo nella tabella, si accorge che รจ
un TEXT, crea un parametro nvarchar(max) e lo passa alla query che a
questo punto schianta.

Cosa sbaglio?

Daniele

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to