locked
Filtering using date and eq operator RRS feed

  • Question

  •  

    Hi,

     

    We're trying to filter results based on a date eg:

     

    http://localhost/DataService/PersonDataService.svc/Person()?$filter=PersonDate eq '9999-12-31'

     

    and we're getting the exception:

     

    The binary operator Equal is not defined for the types 'System.DateTime' and 'System.String'.

     

    I've included the stack trace below.

     

    This was working in the SP1 (beta 1) release but since upgrading to SP1 RTM it's not.

     

    Any help will be much appreciated!

     

     

     

     

     

       at System.Linq.Expressions.Expression.GetEqualityComparisonOperator(ExpressionType binaryType, String opName, Expression left, Expression right, Boolean liftToNull)
       at System.Linq.Expressions.Expression.Equal(Expression left, Expression right, Boolean liftToNull, MethodInfo method)
       at System.Linq.Expressions.Expression.Equal(Expression left, Expression right)
       at System.Data.Services.Parsing.RequestQueryParser.ExpressionParser.GenerateEqual(Expression left, Expression right)
       at System.Data.Services.Parsing.RequestQueryParser.ExpressionParser.ParseComparison()
       at System.Data.Services.Parsing.RequestQueryParser.ExpressionParser.ParseLogicalAnd()
       at System.Data.Services.Parsing.RequestQueryParser.ExpressionParser.ParseLogicalOr()
       at System.Data.Services.Parsing.RequestQueryParser.ExpressionParser.ParseExpression()
       at System.Data.Services.Parsing.RequestQueryParser.ExpressionParser.ParseWhere()
       at System.Data.Services.Parsing.RequestQueryParser.ParseLambdaForWhere(IDataService service, Type typeForIt, String expression)
       at System.Data.Services.Parsing.RequestQueryParser.Where(IDataService service, IQueryable source, String predicate)
       at System.Data.Services.RequestQueryProcessor.ProcessFilter()
       at System.Data.Services.RequestQueryProcessor.ProcessQuery()
       at System.Data.Services.RequestQueryProcessor.ProcessQuery(IDataService service, RequestDescription description)
       at System.Data.Services.RequestUriProcessor.ProcessRequestUri(Uri absoluteRequestUri, IDataService service)
       at System.Data.Services.DataService`1.ProcessIncomingRequestUriAndCacheHeaders()
       at System.Data.Services.DataService`1.HandleRequest()

    Thursday, August 14, 2008 2:49 AM

All replies

  • Hi,

     

    It seems that the URL syntax has changed so that dates now need to be prefixed by "datetime" so that the above query has changed to:

     

    http://localhost/DataService/PersonDataService.svc/Person()?$filter=PersonDate eq datetime'9999-12-31'

     

    Does anyone know where the new syntax/documentation can be found?

     

    Thanks!

     

    Thursday, August 14, 2008 4:11 AM