Question

how do you pass long type parameter with data services? It passes INT with no problems, but what could be the solution for LONG? I tried the method that I use for strings for joke, doesn't seem to work.

public TransactionCartItem GetTransactionCartItemByTransactionNumber(long transactionNumber)
{
    transactionNumber = (int)transactionNumber; // it works if I convert to INT (just for debugging reason I tried)

    var query =
        this.ClientRepositories
            .Context
            .CreateQuery<TransactionCartItem>("GetTransactionCartItemByTransactionNumber")
            .AddQueryOption("transactionNumber", transactionNumber)
            .FirstOrDefault();

    return query;
}

Error for LONG usage:

“Bad Request - Error in query syntax.”

Was it helpful?

Solution

I think OData needs long (Int64) values in Url to be appended with L.

Try this and let us know.

public TransactionCartItem GetTransactionCartItemByTransactionNumber(long transactionNumber)
{   
    var query =
        this.ClientRepositories
            .Context
            .CreateQuery<TransactionCartItem>("GetTransactionCartItemByTransactionNumber")
            .AddQueryOption("transactionNumber", transactionNumber + "L")
            .FirstOrDefault();

    return query;
}

got the documentation.. the Edm.Int64 seems to need a trailing L at the end. http://www.odata.org/documentation/odata-version-2-0/overview/#AbstractTypeSystem

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top