Odata substringof错误

时间:2014-06-12 09:06:44

标签: asp.net vb.net asp.net-mvc-4 nhibernate odata

我到处寻找,无法找到解决此错误的方法 我正在尝试在客户 webapi控制器上使用substringof。

URL:

http://mytestsite.com:54516/api/Customer?$filter=substringof(Name, 'pro')

我收到以下错误:

{"Message":"An error has occurred.","ExceptionMessage":"Der blev udløst en undtagelse af typen 'Antlr.Runtime.NoViableAltException'. [.Count[RTC.DataContext.Entities.CustomerEntity](.Where[RTC.DataContext.Entities.CustomerEntity](NHibernate.Linq.NhQueryable`1[RTC.DataContext.Entities.CustomerEntity], Quote(($it, ) => (Equal(Or(p1, Equal($it.Name, NULL)) ? NULLp3 : Convert(p2.Contains($it.Name, )), p4))), ), )]","ExceptionType":"NHibernate.Hql.Ast.ANTLR.QuerySyntaxException","StackTrace":"   ved NHibernate.Hql.Ast.ANTLR.ErrorCounter.ThrowQueryException()\r\n   ved NHibernate.Hql.Ast.ANTLR.HqlSqlTranslator.Translate()\r\n   ved NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.DoCompile(IDictionary`2 replacements, Boolean shallow, String collectionRole)\r\n   ved NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IASTNode ast, String queryIdentifier, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory)\r\n   ved NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(String queryIdentifier, IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory)\r\n   ved NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow, IDictionary`2 enabledFilters)\r\n   ved NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow)\r\n   ved NHibernate.Impl.AbstractSessionImpl.CreateQuery(IQueryExpression queryExpression)\r\n   ved NHibernate.Linq.DefaultQueryProvider.PrepareQuery(Expression expression, IQuery& query, NhLinqExpression& nhQuery)\r\n   ved NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression)\r\n   ved NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression expression)\r\n   ved System.Linq.Queryable.Count[TSource](IQueryable`1 source)\r\n   ved RTC.CustomerController.GetValues(ODataQueryOptions`1 query) i C:\\Projects\\Radiometer LMS\\RTC\\Development\\RTC Training manager\\Controllers\\Api\\CustomerController.vb:linje 34\r\n   ved lambda_method(Closure , Object , Object[] )\r\n   ved System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters)\r\n   ved System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n   ved System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c__DisplayClass5.<ExecuteAsync>b__4()\r\n   ved System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)"}

对我来说,似乎它插入了null而不是我在网址中使用的 pro

遇到此错误并知道该怎么做的任何人?

控制器:

<HttpGet, Queryable(AllowedQueryOptions:=AllowedQueryOptions.All,     HandleNullPropagation:=HandleNullPropagationOption.False, PageSize:=20)> _
Public Function GetValues(query As ODataQueryOptions(Of CustomerEntity)) As IEnumerable(Of CustomerModel.CustomerListModel)
    query.Validate(New ODataValidationSettings())

    Dim myModel As IQueryable(Of CustomerEntity)
    If CurrentUser.IsInRole("Customeradmin") Then
        myModel = CurrentUser.Region.Customers
    Else
        myModel = Repository.Query(Of CustomerEntity)()
    End If
    If (Not IsNothing(query.Filter)) Then
        myModel = query.Filter.ApplyTo(myModel, New ODataQuerySettings())
    End If
    If (Not IsNothing(query.OrderBy)) Then
        myModel = query.OrderBy.ApplyTo(myModel)
    End If

    Dim count = myModel.Count()

    If (Not IsNothing(query.Skip)) Then
        myModel = myModel.Skip(query.Skip.Value)
    End If
    If (Not IsNothing(query.Top)) Then
        myModel = myModel.Take(query.Top.Value)
    End If
    If (Not IsNothing(query.OrderBy)) Then
        myModel = query.OrderBy.ApplyTo(myModel)
    End If
    Dim res = myModel.Select(Function(c) New CustomerModel.CustomerListModel() With {

我正在使用以下内容:
ASP.net MVC4
Microsoft.data.Odata v5.6.1.0(最新)
fluentNhibernate v1.4.0.0(最新)
Nhibernate v3.3.1.4001(最新)
NHibernate.Odata v0.4.0.0(最新)

0 个答案:

没有答案