Waqas Kanju Waqas Kanju - 2 months ago 13
C# Question

How to delete particular record in azure mobile Service

How to delete particular record in azure mobile Service.
For Example I have a table in azure mobile service called country having two columns
country_id
country_name

If I want to delete the record with country_id=5. How to Perform this.

//Global Variable

private MobileServiceCollection<country, country> items;
private IMobileServiceTable<country> todoTable = App.MobileService.GetTable<country>();


// Class

class country
{
public string id { get; set; }
public string country_name { get; set; }
public int country_id { get; set; }
}

Answer

You'll need to call DeleteAsync and pass the item you'd like to delete. In this case, the item that has your country_id.

await todoTable.DeleteAsync(country);

You can read more documentation here: https://azure.microsoft.com/en-us/documentation/articles/mobile-services-windows-dotnet-how-to-use-client-library/#deleting

Comments