I know what I am doing tonight
Download Windows Phone Developer Tools Beta
I know what I am doing tonight
Download Windows Phone Developer Tools Beta
I read a good post recently on Windows Phone 7 Data Json WCF Data Service with IIS 7 Compression by Nick Randolph blog. I thought I would give it a go minus the IIS compression to see if I could quickly generate a service reference using the VS 2010 Express for Windows Phone April CTP. I found that currently there were a number of issues with the OData Client Library for Windows Phone 7 Series CTP and adding service references to a WCF Data Service in the CTP of VS – rest assured I am sure they will get sorted by the time things go RTM. In the mean time these are the steps I used:
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
DataSvcutil.exe /uri:http://localhost/TestDataService/Test.svc/ /DataServiceCollection /Version:2.0 /out:D:\dev\TestSol\TestWCFDataService\Providers\TestClient.cs
Hint: drop this into a batch file for later ease of update as your service definition changes.
<Grid Grid.Row="1" x:Name="ContentGrid" Grid.Column="0">
<ListBox ItemsSource="{Binding Patients}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding FirstName}" Margin="5,5,5,5"/>
<TextBlock Text="{Binding LastName}" Margin="5,5,5,5"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
public MainPage()
{
InitializeComponent();
SupportedOrientations = SupportedPageOrientation.Portrait | SupportedPageOrientation.Landscape;
this.DataContext = ViewModel;
ViewModel.GetPatients(20);//future posts will look at using WCF serverside paging
}
private MainPageViewModel _viewModel;
public MainPageViewModel ViewModel
{
get
{
if (_viewModel == null)
_viewModel = new MainPageViewModel();
return _viewModel;
}
set { _viewModel = value; }
}
using System;
using System.Data.Services.Client;
using System.Linq;
namespace TestDataService.ViewModels
{
public class MainPageViewModel
{
private TestClient _context;
public PatientViewModel()
{
_context = new TestClient(new Uri("http://localhost/TestDataService/Test.svc/"));//Externalise url to isolated storage
Patients = new DataServiceCollection<Patient>();
}
public void GetPatients(int count)
{
Patients.LoadAsync(_context.Patients.Take(count));
}
public DataServiceCollection<Patient> Patients{ get; set; }
}
}
In summary, I cant wait until this goes RTM and becomes just as quick to work with as the serverside component. I will look at WCF Data Service serverside paging and QueryInterceptors in a coming post.
I am being dragged away from the computer for the weekend
but will try to get the OData post I have been working on done when I return. Until then some good reading material for all those who are intending on releasing a Windows Phone 7 application to marketplace – Windows Phone 7 Application Certification Requirements
Nick Harris is a Senior Technical Evangelist at Microsoft specializing in Windows Azure. Before Microsoft, he founded his own startup AdGAC a mobile advertising company developed utilizing Windows Azure, WP7 and ASP.NET MVC. In the 9 years prior, Nick worked as both a consultant and Senior Software Engineer delivering smart client applications, distributed enterprise applications and airborne software systems. While not working you can find him blogging or on Twitter about Windows Azure along with a diverse range of related technical content.