none
[Node.js][Mobile Apps][Xamarin ] Executing a custom SQL query inside a read Table Script enter infinite loop RRS feed

  • Question

  • calling PullAsync never return results back  but if i remove the offline support everything works fine

    Node js Code

    --------------------------------------------------------

    var azureMobileApps = require('azure-mobile-apps'),
        promises = require('azure-mobile-apps/src/utilities/promises'),
        logger = require('azure-mobile-apps/src/logger');

    var table = azureMobileApps.table();

    var readMiddleware = function(req, res, next) {

        console.log('.........To Debug...............');

        var filter = JSON.stringify(req.query.$filter);
        var post = filter.match(/'([^']+)'/)[1];
        var parameters = [{
            name: 'param1',
            value: post
        }, ];

        var query = {
            sql: "exec GetPostComments @param1",
            parameters: parameters
        };

        req.azureMobile.data.execute(query).then(function(results) {
            req.queryResult = results;
            next();
        });
    };

    table.read.use(readMiddleware, table.operation);

    table.read(function(context) {

        context.res.send(context.req.queryResult);

    });

    Xamarin Code    

    --------------------------------------------------------

    public async Task<List<AzurePostComments>> SyncCommentAsync(string post)
            {
                ReadOnlyCollection<MobileServiceTableOperationError> syncErrors = null;

                try
                {
                    await this.Client.SyncContext.PushAsync();

                    // The first parameter is a query name that is used internally by the client SDK to implement incremental sync.
                    // Use a different query name for each unique query in your program.
                    await this.azureComment.PullAsync(
    posthis.azureComment.CreateQuery().Where(po => po.Post == post));

                    List<AzurePostComments> comments = await this.azureComment.Where(po => po.Post == post).ToListAsync();
                    return comments;
                }
                catch (MobileServicePushFailedException exc)
                {
                    if (exc.PushResult != null)
                    {
                        syncErrors = exc.PushResult.Errors;
                    }
                }

            }

    Azure Stream Logs

    --------------------------------------------------------

       


    Mostafa Sany Khodeir

    Sunday, December 10, 2017 8:22 PM