update

Getting productive with WAMS: how to update data for a specific row in a table

WAMS.png

Like I promised, I will share some of the Azure goodness I learned during creating my last app.

This post is all about how to update a specific table entry (like a user’s data) in a Azure SQL table from an Windows Phone app.

First, we need to make sure that there is some data from the user we want to update. I used the LookupAsync () method to achieve that.

IMobileServiceTable<userItems> TableToUpdate = App.MobileService.GetTable<userItems>();
IMobileServiceTableQuery<userItems> query = TableToUpdate.Where(useritem => useritem.TwitterId == App.TwitterId);

var useritemFromAzure = await query.ToListAsync();
var useritemLookUp = await TableToUpdate.LookupAsync(useritemFromAzure.FirstOrDefault<userItems>().Id);

If we want a specific entry, we need a search criteria to find our user and fetch the id of the user’s table entry. In my case, I used the Twitter Id for the query as every user has this on my project.

Now that we have the table row id, we can easily update the data of this specific row with the UpdateAsync() method.

We need to declare which columns should be updated and asign the values to it first. After that, we simply call the UpdateAsync() method.

useritemLookUp.TwitterId = App.TwitterId;
useritemLookUp.LastCheckedAt = DateTime.Now;
useritemLookUp.OSVersion = "WP8";
useritemLookUp.AppVersion = App.VersionNumber;

await TableToUpdate.UpdateAsync(useritemLookUp);

Please note that you need a items class/model to create the update data (which you should have already before thinking about updating the data).

You should wrap this code in a try{}/catch{} block to be able to react to the Exceptions that possibly can be thrown and display a matching message to the user.

That’s already all about updating a specific row in a WAMS SQL table.

As always I hope this post is helpful for some of you.

Happy coding!

Posted by msicc in Azure, Dev Stories, 1 comment
Fishing Knots + update to version 1.6 and some other changes

Fishing Knots + update to version 1.6 and some other changes

Today I submitted version 1.6 of Fishing Knots to the Marketplace.

It contains only a few new features:

– overhauled user interface

– integrated Italian and German language

– minor bug fixes

Here is a short video that demonstrates the new version:

Breaking changes are coming to “Angelknoten +” and “Nodi della pesca +”.

As I integrated the German and Italian language in Fishing Knots to make it easier for me to maintain the app (one is easier than three), both before mentioned apps will be discontinued.

Once you installed the update to 1.5.9, you will be prompted to install “Fishing Knots +”. The app will be free for one week to give everybody the possibility to install it for free.

Why am I doing this?

That´s relatively easy to explain: This was my first app ever and I wasn’t aware of the localization possibilities in the beginning of development. So I did three apps. Now that I know how I can integrate additional languages to an app, this has to be changed.

I am sorry for any inconvenience and hope you will understand this move.

“Fishing Knots +” will be the version I will update constantly.

Posted by msicc in Archive, 0 comments