You have ignored what i said.
Repeating one last time

.AddOrder(Order.Asc(Projections.SqlProjection("SCORE(1) as dummy",new
[]{"dummy"},new []{NHibernateUtil.String} )));


Tuna Toksöz
Eternal sunshine of the open source mind.

http://devlicio.us/blogs/tuna_toksoz
http://tunatoksoz.com
http://twitter.com/tehlike




On Thu, Jul 16, 2009 at 9:38 PM, Colin Bowern <[email protected]> wrote:

>
> Lets make the scenario simpiler:
>
> SELECT
>     Id,
>     Name,
> FROM
>     Widgets
> WHERE
>     CONTAINS('fulltextcolumn', 'Foo Bar', 1) > 0
> ORDER BY
>     SCORE(1)
>
> If I wanted to add an order by using a function how would I approach
> that with NH/Fluent?  The Score(1) doesn't map to the entity and I
> don't expect it to be returned.  If I add it using:
>
> criteria.AddOrder(new Order(Projections.SqlProjection("SCORE(1)", new
> string[] { "Score" }, new NHibernate.Type.IType[]
> { NHibernateUtil.Int32 } ), false));
>
> I get:
>
> System.ArgumentException was unhandled by user code
>  Message="length should be greater than or equal to 0\r\nParameter
> name: length"
>  Source="NHibernate"
>  ParamName="length"
>  StackTrace:
>       at NHibernate.SqlCommand.SqlString.Substring(Int32 startIndex,
> Int32 length)
>       at NHibernate.Util.StringHelper.RemoveAsAliasesFromSql
> (SqlString sql)
>       at NHibernate.Criterion.Order.ToSqlString(ICriteria criteria,
> ICriteriaQuery criteriaQuery)
>       at NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetOrderBy
> ()
>       at NHibernate.Loader.Criteria.CriteriaJoinWalker..ctor
> (IOuterJoinLoadable persister, CriteriaQueryTranslator translator,
> ISessionFactoryImplementor factory, ICriteria criteria, String
> rootEntityName, IDictionary`2 enabledFilters)
>       at NHibernate.Loader.Criteria.CriteriaLoader..ctor
> (IOuterJoinLoadable persister, ISessionFactoryImplementor factory,
> CriteriaImpl rootCriteria, String rootEntityName, IDictionary`2
> enabledFilters)
>       at NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria,
> IList results)
>       at NHibernate.Impl.CriteriaImpl.List(IList results)
>       at NHibernate.Impl.CriteriaImpl.List[T]()
>       at foo.Common.Services.Repositories.Repository`1.FindAll
> (Criteria query) in C:\Projects\foo\Trunk\Source\foo.Common.Services
> \Repositories\Repository.cs:line 202
>       at foo.Services.fooService.FindAllBar(CriteriaDto criteriaDto)
> in C:\Projects\foo\Trunk\Source\RealCondition.Services
> \fooService.cs:line 40
>       at SyncInvokeFindAllBuildingItems(Object , Object[] , Object
> [] )
>       at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke
> (Object instance, Object[] inputs, Object[]& outputs)
>       at
> System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin
> (MessageRpc& rpc)
>  InnerException:
>
>
> Thoughts?
>
> Thanks,
> Colin
>
>
> On Jul 10, 12:32 pm, Tuna Toksoz <[email protected]> wrote:
> > Score may be a special word (and it seems like it is) so change "Score"
> to
> > sscore or sometihng.
> >
> > Tuna Toksöz
> > Eternal sunshine of the open source mind.
> >
> >
> http://devlicio.us/blogs/tuna_toksozhttp://tunatoksoz.comhttp://twitter.com/tehlike
> >
> >
> >
> > On Fri, Jul 10, 2009 at 7:32 PM, Tuna Toksoz <[email protected]> wrote:
> > > Projections.SqlProjection("SCORE(1) as Score",
> > >                                       new string[] { "Score" },
> > >                                       new
> > > NHibernate.Type.IType[]{NHibernateUtil.Int32})
> >
> > > Try this
> >
> > > You can also use SqlFunctionProjection
> >
> > > Tuna Toksöz
> > > Eternal sunshine of the open source mind.
> >
> > >http://devlicio.us/blogs/tuna_toksoz
> > >http://tunatoksoz.com
> > >http://twitter.com/tehlike
> >
> > > On Fri, Jul 10, 2009 at 7:27 PM, Tuna Toksoz <[email protected]>
> wrote:
> >
> > >> What error do you get and what is the exception you get?
> >
> > >> Tuna Toksöz
> > >> Eternal sunshine of the open source mind.
> >
> > >>http://devlicio.us/blogs/tuna_toksoz
> > >>http://tunatoksoz.com
> > >>http://twitter.com/tehlike
> >
> > >> On Fri, Jul 10, 2009 at 7:15 PM, Colin Bowern <[email protected]>
> wrote:
> >
> > >>> CORE(1)- Hide quoted text -
> >
> > - Show quoted text -
> >
>

--~--~---------~--~----~------------~-------~--~----~
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