티스토리 뷰

 

 

Windows Azure - Mobile Services (4)

 

포럼에 질문이 올라와서 Mobile Services 데이터 페이징에 대한 내용을 정리합니다. Windows 8 App을 개발하실때 참조하실수 있습니다.

관련 내용은 아래 링크의 NOTE 부분을 참고하시기 바랍니다.

http://www.windowsazure.com/en-us/develop/mobile/tutorials/add-paging-to-data-dotnet/

To prevent data overflow in mobile device clients, Mobile Services implements an automatic page limit, which defaults to a maximum of 50 items in a response. By specifying the page size, you can explicitly request up to 1,000 items in the response.

 

Windows Azure Mobile Services는 기본적으로 50건의 데이터를 가져오도록 되어 있습니다. Take 메서드를 쓰면 1,000개까지 지원이 가능하며 페이징으로 구현할수 있습니다.

 

Mobile Services의 경우 실제 데이터는 아래 그림처럼 50건 이상이 있습니다.

 

기본적인 아래 쿼리 구문으로 데이터를 조회하면 해당 데이터는 50건만 나타나게 됩니다.

private void RefreshTodoItems()

        {

            // This code refreshes the entries in the list view be querying the TodoItems table.

            // The query excludes completed TodoItems

            items = todoTable

                .Where(todoItem => todoItem.Complete == false)

                .ToCollectionView();

            ListItems.ItemsSource = items;

        }

 

페이징에 대한 내용은 SKIP, TAKE 메서드를 통해 구현이 가능합니다. 51 건 이후의 2 페이지를 검색해보겠습니다.

private void RefreshTodoItems()

        {

            // This code refreshes the entries in the list view be querying the TodoItems table.

            // The query excludes completed TodoItems

            items = todoTable

                .Where(todoItem => todoItem.Complete == false).Skip(50).Take(50)

                .ToCollectionView();

            ListItems.ItemsSource = items;

        } 

1,000 건을 들고와 보겠습니다. 잘 동작합니다.

items = todoTable

                .Where(todoItem => todoItem.Complete == false).Take(1000)

                .ToCollectionView();

            ListItems.ItemsSource = items;

10,000 건을 들고오면 아래와 같이 Exception이 발생하게 됩니다. 1,001 을 조회하려고 해도 마찬가지로 오류가 발생합니다.

items = todoTable

                .Where(todoItem => todoItem.Complete == false).Take(10000)

                .ToCollectionView();

            ListItems.ItemsSource = items;

 

한꺼번에 1,000건 이상의 데이터를 다 들고 와서 App에서 사용하려고 한다면 WebAPI, REST 서비스를 별도로 만들어야 할 것으로 보입니다.

간략하게 Windows Azure Mobile Services 에 대한 데이터 페이징을 알아보았습니다.

'Microsft Azure' 카테고리의 다른 글

Service Bus - Preview Portal  (0) 2012.10.08
Windows 스토어 & Windows Azure Web Sites  (0) 2012.10.08
Windows Azure Update - 9월  (0) 2012.09.20
Windows Azure – Mobile Services (3)  (0) 2012.09.10
Windows Azure – Mobile Services (2)  (0) 2012.09.07
댓글