locked
Problem querying tinyint RRS feed

  • Question

  • dailyeventnumber is type tinyint

     

    LegacyRecords?$filter=dailyeventnumber eq 0 & $top=5

    gives error:

    Operator 'eq' incompatible with operand types 'Byte?' and 'Int32' at position 17.

     

    try casting:

    LegacyRecords?$filter=cast(dailyeventnumber, 'System.Int32') eq 0 & $top=5

    gives error:

    No applicable function found for 'cast' at position 0 with the specified arguments. The functions considered are: cast(System.Type); cast(System.Object, System.Type)

    try Linq:

    var query = (from rec in ctx.LegacyRecords

    where rec.dailyrunnernumber == 0

    select rec).Take(countReqd);

     

    translates to:

    LegacyRecords?$filter=(cast((dailyrunnernumber),%20'System.Nullable%601%5B%5BSystem.Int32,%20mscorlib,%20Version=2.0.0.0,%20Culture=neutral,%20PublicKeyToken=b77a5c561934e089%5D%5D'))%20eq%20(0)&$top=5

    and gives error:

    No applicable function found for 'cast' at position 1 with the specified arguments. The functions considered are: cast(System.Type); cast(System.Object, System.Type).

     

    Queries against types int and smallint work fine.

    Wednesday, March 19, 2008 5:13 PM

All replies

  • Have you tried adding an explicit cast as per: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2948870&SiteID=1

     

     

    Monday, March 31, 2008 11:24 PM
  • Hi Mike

     

    Well, as I said before, I tried

     

    LegacyRecords?$filter=cast(dailyeventnumber, 'System.Int32') eq 0 & $top=5

     

    and got the error:

    No applicable function found for 'cast' at position 0 with the specified arguments. The functions considered are: cast(System.Type); cast(System.Object, System.Type)

     

     

    Looking at what Linq produces:

    var query = (from rec in ctx.LegacyRecords

    where rec.dailyeventnumber == 0

    select rec).Take(countReqd);

     

    translates to:

    LegacyRecords?$filter=(cast((dailyeventnumber),%20'System.Nullable%601%5B%5BSystem.Int32,%20mscorlib,%20Version=2.0.0.0,%20Culture=neutral,%20PublicKeyToken=b77a5c561934e089%5D%5D'))%20eq%20(0)&$top=5

     

    this gives the same error:

    No applicable function found for 'cast' at position 1 with the specified arguments. The functions considered are: cast(System.Type); cast(System.Object, System.Type).

     

    Am I doing something wrong in the cast? (I can't find much documentation for it)

     

    regards

    John

     

    Tuesday, April 1, 2008 11:51 AM