locked
Store app vb.net code throwing an error with Azure

    Question

  • Hi,

    I am looking to extend the default number of records I can download to a store app from Azure using mobile services.

    I found this below blog that has the code for exactly what I want but when I convert the C# to vb.net, I get an issue.

    http://www.kevinashley.com/2013/02/retrieving-more-data-from-azure-mobile-services-using-paging/

    I convert the c# code to the below vb.net code but the line - table As MobileServiceTableQuery(Of T) - gives me this error

    'Microsoft.WindowsAzure.MobileServices.MobileServiceTableQuery(Of T)' is not accessible in this context because it is 'Friend'.

    Can anyone advise me of what the issue is here and how I could work around it.

    Thanks for all help.

        <System.Runtime.CompilerServices.Extension> _
        Public Shared Async Function LoadAllAsync(Of T)(table As MobileServiceTableQuery(Of T), Optional bufferSize As Integer = 1000) As Task(Of List(Of T))
            Dim query = table.IncludeTotalCount()
            Dim results = Await query.ToEnumerableAsync()
            Dim count As Long = DirectCast(results, ITotalCountProvider).TotalCount
            If results IsNot Nothing AndAlso count > 0 Then
                Dim updates = New List(Of T)()
                While updates.Count < count
    
                    Dim [next] = Await query.Skip(updates.Count).Take(bufferSize).ToListAsync()
                    updates.AddRange([next])
                End While
                Return updates
            End If
    
            Return Nothing
        End Function

    Wednesday, September 24, 2014 11:43 PM

Answers

  • Hi Ireland,

    A very easy way to solve this issue is to create a new C# project in your solution. Copy the code into the C# project, add C# project reference to your VB.NET project and then you can use the C# code in your VB.NET code directly.

    If you want to fix the converted VB code, I would recommend you open a new thread in VB.NET forum for response. I’m not familiar with VB.NET code. Please refer to http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vbgeneral

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Ireland75 Thursday, September 25, 2014 9:14 AM
    • Unmarked as answer by Ireland75 Thursday, September 25, 2014 9:18 AM
    • Marked as answer by Ireland75 Thursday, September 25, 2014 9:18 AM
    Thursday, September 25, 2014 8:26 AM
    Moderator
  • hi,

    got it working as below.  looks like MobileServiceTableQuery was deprecated or updated to IMobileServiceTable

    <System.Runtime.CompilerServices.Extension> _
        Public Shared Async Function LoadAllAsync(Of T)(table As IMobileServiceTable(Of T), Optional bufferSize As Integer = 1000) As Task(Of List(Of T))
            Dim query = table.IncludeTotalCount()
            Dim results = Await query.ToEnumerableAsync()
            Dim count As Long = DirectCast(results, ITotalCountProvider).TotalCount
            If results IsNot Nothing AndAlso count > 0 Then
                Dim updates = New List(Of T)()
                While updates.Count < count

                    Dim [next] = Await query.Skip(updates.Count).Take(bufferSize).ToListAsync()
                    updates.AddRange([next])
                End While
                Return updates
            End If

            Return Nothing
        End Function

    • Marked as answer by Ireland75 Thursday, September 25, 2014 3:07 PM
    Thursday, September 25, 2014 3:07 PM

All replies

  • Hi Ireland,

    A very easy way to solve this issue is to create a new C# project in your solution. Copy the code into the C# project, add C# project reference to your VB.NET project and then you can use the C# code in your VB.NET code directly.

    If you want to fix the converted VB code, I would recommend you open a new thread in VB.NET forum for response. I’m not familiar with VB.NET code. Please refer to http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vbgeneral

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Ireland75 Thursday, September 25, 2014 9:14 AM
    • Unmarked as answer by Ireland75 Thursday, September 25, 2014 9:18 AM
    • Marked as answer by Ireland75 Thursday, September 25, 2014 9:18 AM
    Thursday, September 25, 2014 8:26 AM
    Moderator
  • thanks for your reply Herro...ill try an vb.net forum first and if no luck ill try your idea.

    thanks

    Thursday, September 25, 2014 9:14 AM
  • hi,

    got it working as below.  looks like MobileServiceTableQuery was deprecated or updated to IMobileServiceTable

    <System.Runtime.CompilerServices.Extension> _
        Public Shared Async Function LoadAllAsync(Of T)(table As IMobileServiceTable(Of T), Optional bufferSize As Integer = 1000) As Task(Of List(Of T))
            Dim query = table.IncludeTotalCount()
            Dim results = Await query.ToEnumerableAsync()
            Dim count As Long = DirectCast(results, ITotalCountProvider).TotalCount
            If results IsNot Nothing AndAlso count > 0 Then
                Dim updates = New List(Of T)()
                While updates.Count < count

                    Dim [next] = Await query.Skip(updates.Count).Take(bufferSize).ToListAsync()
                    updates.AddRange([next])
                End While
                Return updates
            End If

            Return Nothing
        End Function

    • Marked as answer by Ireland75 Thursday, September 25, 2014 3:07 PM
    Thursday, September 25, 2014 3:07 PM