November, 2011

  • Wriju's BLOG

    Azure OData and Windows Phone 7

    • 0 Comments

    In this post I am planning to cover the topic where we will be exposing data in SQL Azure using WCF Data Services and consume it from Windows Phone 7.

    We have data available in SQL Azure. So we will create one let’s say and application ASP.NET MVC and add the Entity Framework data model there.

    image

    After we have added the model we will build the project and add one WCF Data Services file and modify the generated code as below,

    public class EmpDS : DataService<DBAzEntities>
    {
        public static void InitializeService(DataServiceConfiguration config)
        {
            config.SetEntitySetAccessRule("*", EntitySetRights.All);
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
        }
    
        protected override DBAzEntities CreateDataSource()
        {
            DBAzEntities ctx = new DBAzEntities();
            ctx.ContextOptions.ProxyCreationEnabled = false;
            return ctx;
        }
    }
    

    After that upload it to the Azure Hosted services. Once that is done we now can view it in browser to check the validity of the URL. This would allow you to view your data in browser. After that we will build the Windows Phone 7 application to consume the data.

    Build Windows Phone 7 Silverlight application and add “Service Reference” pointing to the URL

    image

    After that write the below code to MainPage.xaml

    public DataServiceCollection<Emp> Emps { get; set; } 
    
    public void LoadData()
    {
        DBAzEntities ctx = new DBAzEntities(new Uri(@"http://127.0.0.1:81/Models/EmpDS.svc/"));
    
        Emps = new DataServiceCollection<Emp>();
        var query = from em in ctx.Emps
                    select em;
        Emps.LoadCompleted += new EventHandler<LoadCompletedEventArgs>(Emps_LoadCompleted);
        Emps.LoadAsync(query);
    }
    
    void Emps_LoadCompleted(object sender, LoadCompletedEventArgs e)
    {
        lstData.ItemsSource = Emps;
    }
    

    And the corresponding XAML would look like,

    <ListBox x:Name="lstData" >
        <ListBox.ItemTemplate>
            <DataTemplate>                    
                <StackPanel>
                    <TextBlock Text="{Binding Path=FullName}"></TextBlock>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>            
    

    And the final output would look like

    image

    Namoskar!!!

  • Wriju's BLOG

    Every Share Point 2010 is OData Server

    • 3 Comments

    If you have a SharePoint 2010 site you can get all the data stored within it as OData Feed. Like I have a site with URL http://sharepoint/sites/demosite, you just need to add this portion to the URL _vti_bin/listdata.svc.

    This would give you the list of Entities within that SharePoint site.

    Namoskar!!!

  • Wriju's BLOG

    How to connect to Hosted TFS using Visual Studio 2010

    • 1 Comments

    You can connect to hosted TFS (Team Foundation Server) from Visual Studio 2010. But to do that you need to install the patch along with Visual Studio 2010 SP1. The patch is available at

    http://go.microsoft.com/fwlink/?LinkId=227805

    After that it is very simple. Add the URL

    image

    image

    After that it will ask for the login. So pass your Live Id.

    image

    image

    Bingo, you are done.

    image

    Note. This is preview release and you get only one Team Collection.

    Namoskar!!!

Page 1 of 1 (3 items)