连接的Windows Phone和Windows 8的应用程序到SQL Server [英] Connect Windows Phone and Windows 8 apps to SQL Server

查看:141
本文介绍了连接的Windows Phone和Windows 8的应用程序到SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是直接连接在Windows Phone应用程序或Windows 8应用到的SQL Server的最佳方法?

What is the best method to connect a Windows Phone app or Windows 8 app directly to an SQL Server?

这些应用不能使用代理/ IIS等,并希望能直接使用SQL就像普通的桌面应用程序连接。

The apps must not use a proxy/IIS etc. and was hoping to connect directly using SQL like with normal desktop applications.

感谢。

推荐答案

您不能直接连接到SQL Server,因为地铁应用程序沙箱的概念。他们只能通过一个服务的服务器comunicate。绕过这个限制,我知道的唯一方法是一个 SQLite的整合进入Windows 8应用程序。

You can't directly connect to a SQL Server, because of the Metro-Apps-Sandbox concept. They only can comunicate with a server through a service. The only way around this limitation that I know of is a SQLite integration into Windows 8 Apps.

在我看来最好的方式(如果你使用Visual Studio)是的的EntityFramework 。这似乎在一开始有点复杂,但 ORM 中确实有帮助,同时开发(通过intellisens少犯错误,更安全针对注射)。然后,你把它包装成一个 WCF数据服务以及你准备使用任何SQL的数据库应用程序中。

In my opinion the best way (if you use Visual Studio) is the EntityFramework. It seems a bit complex at the beginning, but the ORM really helps while developing (less mistakes through intellisens, more security against injections). Then you wrap it up into a WCF Data Service and you are ready to use any SQL-Database in your application.

实体框架允许开发者在特定域的对象和属性,如客户和客户地址的形式数据的工作,而不必与在该数据存储的底层数据库表和列过问。实体框架,开发者可以在抽象的,当他们处理数据更高层次工作,并可以用更少的代码比传统应用

The Entity Framework enables developers to work with data in the form of domain-specific objects and properties, such as customers and customer addresses, without having to concern themselves with the underlying database tables and columns where this data is stored. With the Entity Framework, developers can work at a higher level of abstraction when they deal with data, and can create and maintain data-oriented applications with less code than in traditional applications

您可以两种方法之间做出选择:

You can decide between two ways:


  1. 型号第一 - 设计Visual Studio或SQL Server中的DB Management Studio中

  2. 代码先 - 基于类

  3. 设计你的数据库
  1. Model first - Design your DB inside Visual Studio or SQL Server Management Studio
  2. Code first - Design your DB based on Classes

但也有一些缺点


  • 如果您使用的Windows Azure则不能使用N:M直接的关系,因为一些限制Azure数据库。

  • 您需要致电寻求在Windwos 8开发数据库异步。因此,总有老的客户端使用的EF和Windows 8中的新用途之间的一些困惑。

Here 是EF-项目的页面。你应该从那里开始深入到它。

Here is the Page of the EF-Project. You should start there to dive into it.

这篇关于连接的Windows Phone和Windows 8的应用程序到SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆