且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

连接的Windows Phone和Windows 8的应用程序到SQL Server

更新时间:2022-12-21 18:26:49

您不能直接连接到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.