📜 ⬆️ ⬇️

Windows Azure SQL Databases for Windows Phone 7

The idea of ​​one of the projects that I recently had a chance to work on was to create a database of food products: a bar code, composition, harmful additives, etc. Since this database was supposed to be used on mobile devices, in particular Windows Phone 7, the decision on which storage technologies to use in developing the project tended towards one of the technologies: Windows Azure SQL Databases (WASQLDB) or SQLite for WP 7. However, after prototyping of the project were weighed all the pros and cons of each prototype, and, ultimately, the preference was given to Windows Azure, which we did not regret afterwards. I will try to tell about our experience of using Windows Azure OData in developing an application for Windows Phone 7.

Data transfer from Windows Azure SQL Databases to the client is quite simple with the use of OData WCF Services. OData presents data as sources, which can be accessed by URL, you can change the data using standard HTTP headers. To represent sources as sets of entities associated with OData associations, it uses the links and entities of the EDM model. As a result, access to these services can be obtained from any client that supports OData. Actually, the process itself does not take much time and is a “development in one breath”. I will tell you about how to create a client for receiving data from Windows Azure, namely Windows Azure SQL Databases.

Create a new project ASP.Net Web Application.
')
image

Next, create a connection to WASQLDB. Windows Azure SQL Data Bases - a projection of traditional SQL Server on the cloud, providing opportunities for working with a database through Internet services. This technology allows you to perform relational queries, and also provides functionality for searching, creating analytical reports, integrating and synchronizing data.

image

Before you start creating WCF Data Services, you need data that you have to work with. Entity Framework is used to provide this data.
After the data source settings are completed, we add support for the ADO.NET Entity Framework Model to the project.

image

Next, add the WCF Service to the project and change the code.

image

Now we need to add some code for the newly created Data Service, and edit the first line, specifying the data source that we created earlier. We also establish access rules for tables in the database.

image

At this stage, you can verify the correctness of the work done by running the project. In order to go and see the structure of the database, you must follow the link: http: //localhost:47274/wcfdataservice1.svc/

image

So, the creation of a WCF service is over. Now it remains to create a proxy class for connecting to the service on the client. Run cmd.exe and use the uncomplicated command to create a proxy:

image

As a result, we get the Proxy.cs file, which contains the proxy class. Further we can use this class anywhere - from console to mobile applications. In this case, we will only have to specify the address where the service is located.

Source: https://habr.com/ru/post/154035/


All Articles