6

While researching Metro and WinRT I haven't been able to find anything regarding enterprise apps and database access. All I hear about is the front end development.

Does anyone have any idea of how a Metro app will access a database server? Will this still be done through ASP.Net and ADO.Net? If not, then does anyone have any idea or guess as to how?

1

5 Answers 5

6

It looks like Metro apps will be able acccess enterprise data via web/WCF (Windows Communication Foundation) services (at a minimum.). It looks like you can also use local databases like sqllite, as discussed in the stackexchange thread: https://stackoverflow.com/questions/7746044/using-sqlite-with-winrt

4
  • I'm about to learn ASP.Net, ADO.Net, LINQ, and the Entity Framework in a course I am taking. Do Web/WCF servies hold any place in that area of knowledge or are they something totally different?
    – Ein Doofus
    Feb 8, 2012 at 21:21
  • WCF is a separate subject area. However, knowledge that you pick up that course will likely come into play when you start using WCF.
    – vjones
    Feb 8, 2012 at 21:25
  • Is WCF capable of handling enterprise apps or is something more lightweight?
    – Ein Doofus
    Feb 8, 2012 at 21:37
  • WCF was designed with enterprise apps in mind. It's great.
    – Ian
    May 25, 2012 at 20:24
5

One of .Nets not so hidden gems is WCF Data Services, which in a nutshell allows you to query a Data Model over HTTP, in a very seemless LINQ type way using a protocol called odata. Data services are usually create with Entity Framework, but I believe there are other providers too.

http://msdn.microsoft.com/en-us/library/cc668792.aspx

4

On December 14th, 2011, Microsoft MVP Morten Nielsen said:

You can use HttpClient to download pretty much anything from the web. Why don't you configure your WCF service to return data as JSON, and use the DataContractJsonSerializer to deserialize the results?

And on September 14th, 2011, Microsoft employee Tim Heuer said:

...You cannot directly have a SQL db embedded in your app or use something like ADO.NET. This is more of an async/services infrastructure. So if your data was exposed via services...

Oh and forget about the System.Data namespace. It's not supported in WinRT.

On November 01, 2011, Microsoft employee Immo Landwerth wrote:

When I wrote that .NET for Metro style apps does not include database APIs I bascically meant System.Data. This also includes SqlConnection and SqlCommand, which you would probably need to communicate with the remote SQL Server.


TL;DR

  • You can use HttpClient to download pretty much anything from the web. Configure your WCF service to return data as JSON.
    • If you're developing a XAML application, use the DataContractJsonSerializer class to deserialize the results.
    • If you're developing an HTML5/JS application, use a Javascript library.
1

WinRT has NO system.data and that has been confirmed by Microsoft. System.data has ADO and SQLclient. No direct connect to SQL from WinRT. Need to get data from a service.

1

Just in case you're interested, you can resort to MySQL instead of SQL Server. The MySQL Connector/Net has a WinRT component (DLL) you can reference from your WinRT/UAP Application in order to access a MySQL database. Syntax is similar to "regular" ADO.Net and it's really easy to use.

In case you hold the database in your same machine, you have to enable "localhost" access to WinRT/Metro apps using the CheckNetIsolation cmdlet, as explained here:

https://msdn.microsoft.com/en-US/library/windows/apps/hh780593.aspx

I don't know why Microsoft tries to complicate WinRT development so much, maybe they just don't want LOB applications using WinRT paradigm, but at least with databases we still have an alternative to SQLite to use "real" databases...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.