I've found a solution:

    public override TypedValue[] GetTypedValues(ICriteria criteria,
ICriteriaQuery criteriaQuery)
        {
            List<TypedValue> typedValues = new List<TypedValue>();

            typedValues.Add(new TypedValue(NHibernateUtil.String,
value.ToString(), EntityMode.Poco));

            return typedValues.ToArray();
        }

Daniele

On 16 Dic, 11:58, danyolgiax <[email protected]> wrote:
> I'm trying to implement FREETEXT in Sql Server 2008.
>
> I followed this example:
>
> http://xlib.wordpress.com/2009/12/04/integrating-freetext-search-in-n...
>
> The resultant query is ok (from log file) and works if I copy and
> paste it in SqlServer Management Studio.
>
> If I try to run my application I receive this error:
>
> 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)
>
> What's wrong?
>
> 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