SilverlightShow (@silverlightshow) is a wonderful resource for daily Silverlight and Windows Phone 7 news, exclusive articles, tutorials, videos and training. I would encourage anybody interested in Silverlight, WPF, Windows Phone & other related technologies to check out the SilverlightShow content @ http://silverlightshow.net.
I guest-blogged my 3rd article for SilverlightShow yesterday:
OData seems to have a lot of promise in simplifying data access across multiple platforms by using fundamental technologies of HTTP and Atom/JSon. Using an OData source for data consumption/updates in your Windows Phone application? In this short article, we take a quick look at a data caching strategy in our Windows Phone applications while using an OData data source. While we talk about a Windows Phone solution in particular, these concepts are perfectly applicable when using OData on other mobile platforms.
Full article with screenshots, code samples & downloadable source code can be found HERE.
Also, SilverlightShow was gracious enough to compile my articles in a short eBook, with the overall theme of OData usage in Windows Phone & Azure augmentation of mobile applications. Details HERE.
Cheers SilverlightShow!
Adios
Hi, about the first chapter : SQL Azure Labs for OData dosen’t accept new registrations (http://www.microsoft.com/en-us/sqlazurelabs/labs/frequentlyaskedquestions.aspx)
Second, in the second chapter (Patiend app), for the Cloud app you made 2 CRUD operations (Create and Read). Could you tell me how to make the Update operation ?
Thank you
Hi misiraul,
Thank you for your comments!
Yes, you’re right about the first point. At the time of writing Ch 1, SQL Azure Labs was in CTP and we could configure a SQL Azure DB to have an automatic OData service. This functionality is rumored to return in February. In the meantime, it should be easy to add an OData service to your DB & host it in Azure.
About Ch 2, you can add an Update operation without much difficulty. Please take a look at the ‘AddPatient’ method .. you can do updates similarly: create context, write Linq to select your record & then call ‘context.UpdateObject(..)’.
Makes sense? Please feel free to ping me if you need help with either of these.
Again, thanks for comments!
1. Could you direct me to a OData tutorial for Azure ?
2. Could you be more precise on the Update method ?
Where do you define the relationship between two tables (in SQL Azure, in the edmx,..)?
@misiraul,
1. Check out this series for producing OData: http://www.silverlightshow.net/items/Producing-and-Consuming-OData-in-a-Silverlight-and-Windows-Phone-7-application.aspx. Works the same way no matter where your DB is housed.
2. Table relationships should be defined in SQL Azure .. Entity Data Model will pick up the links. Please see this for Updates: http://www.silverlightshow.net/items/Azure-Services-connecting-Windows-Phone-to-Data.aspx .. define another OperationContract; in the implementation, define context, make changes to records & call UpdateObject, followed by SaveChanges.
That helps?
I managed to make the relationship in SQL Management Studio with a constraint (MS changed today the SQL Azure managemt tool – SL5 )
*about the update :
IService1.cs :
[OperationContract]
string UpdProdus(Produs produs); // my table name is Produs
Service1.svc.cs
public string UpdProdus(Produs produs)
{
try
{
var context = new ContorEntities();
context.Attach(produs);
context.ObjectStateManager.ChangeObjectState(produs, System.Data.EntityState.Modified);
context.SaveChanges();
return “Success!”;
}
catch (Exception e) { return e.Message; }
}
Is this ok by here?
ProductList.xaml
If I want to update a record I should add a TextBox in the Listbox
ProductList.xaml.cs ?
Sounds right Misi!
It is up to you how you want add/edits to work. You could put textboxes inside a listbox, or create a separate XAML page that adds/edits data