Windows 8 Metro 应用程序应如何连接到中央数据库? [英] How should a Windows 8 Metro Application connect to a central database?

查看:18
本文介绍了Windows 8 Metro 应用程序应如何连接到中央数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Windows 8 Metro 应用程序应如何连接到中央数据库?

How should a Windows 8 Metro application connect to a central database?

  • 我读过关于本地存储的文章,但没有读过任何关于连接到中央数据库的文章.
  • 显然,此架构设计决策需要支持断开连接的场景.
  • WCF Web 服务似乎很有意义.
    • 但即使它们确实有意义,我们真的应该为所有读/写操作创建单独的方法吗?
    • 或者 OData WCF 服务是要走的路吗?

    推荐答案

    似乎其他人在 微软开发者论坛.

    这是我发现的:

    根据蒂姆豪雅:

    ...您不能直接在您的应用程序中嵌入 SQL 数据库或使用类似 ADO.NET 的东西.这更像是一个异步/服务基础设施.因此,如果您的数据是通过服务公开的,那么当然你可以这样连接.还有一些其他的轻量级您可以用于本地存储的方法以及使用诸如Windows.Storage 命名空间(类似于独立存储.NET).

    ...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, then of course you could connect that way. There are some other light-weight methods you could use for local storage as well using things like the Windows.Storage namespace (which is similar to Isolated Storage in .NET).

    莫滕尼尔森同意:

    您可以使用 HttpClient 从网络下载几乎所有内容.为什么不将 WCF 服务配置为以 JSON 形式返回数据,并且使用 DataContractJsonSerializer 反序列化结果?

    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?

    另外,蒂姆豪雅注意事项:

    ...请注意,虽然很棒,但 Codeplex 上的 SQLWinRT 项目是一个包装器与经典的 SQLite 引擎进行通信......它使用目前无法通过商店验证的 API.

    ...Please note that while awesome, the SQLWinRT project on codeplex is a wrapper to communicate with the classic SQLite engine...which uses APIs that would not pass store validation currently.

    <小时>

    WinRT 的通用对象存储助手基于 WinRTFile 的数据库 似乎有一些希望.


    Generic Object Storage Helper for WinRT and WinRTFile Based Database seem to have some promise.

    但是 丹尼尔·斯托尔特提出一些优点:

    对于构建 OData 客户端和其他 REST 客户端 - 但这仅适用于在线场景.这Windows.Storage 的结构化"部分是一个非常有限的模型,基本上仅限于名称/值对,除了最基本的场景.是的,有本地文件存储,这很棒当然.但迫使每个应用程序开发人员都建立自己的本地文件存储之上的 DBMS 根本不会削减它,尤其是已从配置文件中删除所有 System.Data. 如果是本地文件存储对于大多数设备应用程序来说已经足够了,然后诸如SQLCE 在今天已经没有意义了.并且 SQLCE 显然有一个目的,并偶尔发挥了非常重要的作用连接设备应用程序很长时间.还有一个巨大的需要与服务器端数据库(如 SQL)同步Azure,主要是为了能够在设备之间漫游数据.就在这里WinRT 中的漫游存储模型,但它具有相同的限制上面提到的本地存储,除此之外非常有限容量(如果有内存,当前为 30KB).简直就是除了最简单的漫游数据需求外,其他方面都不够.再次,迫使每个应用程序开发人员设计和实现自己的同步解决方案很糟糕.你可以做得更好开发人员.

    It's awesome that there is good support for building OData clients and other REST clients - but this only addresses the online scenario. The "structured" part of Windows.Storage is a very limited model, essentially limited to name/value pairs, insufficient for all but the most basic scenarios. Yes there is local file storage, which is great of course. But forcing every app developer out there to build her own DBMS on top of local file storage will simply not cut it, especially with all of System.Data having been removed from the profile. If local file storage was sufficient for most device apps, then things like SQLCE would have no purpose today already. And SQLCE clearly has a purpose, and has played a very important role for occasionally connected device apps for a very long time. There is also a tremendous need for synchronization with a server-side database such as SQL Azure, mostly to be able to roam data between devices. Yes there is the roaming storage model in WinRT, but it shares the same limitations of local storage mentioned above, and on top of this is very limited in capacity (currently 30KB if memory serves). It is simply insufficient for all but the simplest roaming data needs. Again, forcing every app developer to design and implement her own synchronization solution is very bad. You can do much better to enable developers.

    <小时>

    许多人对 WinRT 不支持 System.Data 命名空间感到失望.


    Many people are disappointed that the System.Data namespace is not supported in WinRT.

    Richard Bethell 说:

    我什至无话可说.这是惊人的.留作他们想强迫你抽象到中间件的那一刻数据库连接 - 我不同意,但我可以准理解这样做的理由.我什至可以看到这样的发展途径.

    I don't even have words for this. This is astonishing. Leave aside for the moment they want to force you to abstract to middleware for database connectivity - I don't agree, but I can quasi understand a rationale for that. I can even see pathways for developing like that.

    但根本没有 System.Data....?你甚至明白你做了什么吗给我们?

    But no System.Data.... at all? Do you even understand what you've done to us?

    除了为 Sql 提供提供程序之外,System.Data 还能做什么,OleDb 和 Oracle 等其他自定义提供程序提供了丰富的XML 数据集的抽象,允许您非常快速地构建一个面向数据的面向服务架构.

    What System.Data can do, outside of just having providers for Sql, OleDb and other custom providers like Oracle, is provide a rich abstraction of XML datasets that allow you to very quickly build a data oriented Service Oriented Architecture.

    例如,我可以使用 SOAP 或 WCF 轻松创建一个 Web 服务返回数据集或数据表,然后轻松使用这些对象并直接.能够做到这一点可以非常快速地构建n 层架构,即使没有可用的直接数据连接.

    For instance, I can easily create a web service using SOAP or WCF that returns DataSets or DataTables, and then consume those objects easily and directly. Being able to do this allows very rapid construction of n-tier architectures, even without direct data connections available.

    没有 System.Data,以及 DataViews、DataTables 等的强大功能.变得更加困难.当然你可以自定义创建结构,将数据放入在那里,并提供结构,并使用 Linq 进行任何排序,过滤等你想做的......但它最终是两倍工作,并使代码重用更加困难.这意味着使用我们的现有的面向服务的架构是不可能的(没有一个大的大修.)

    Without System.Data, and the power of DataViews, DataTables, etc. this gets a lot harder. Sure you can custom create structs, put data in there, and serve up structs, and use Linq to do whatever sorting, filtering, etc. you want to do.... but it ends up being twice the work, and makes code reuse a lot harder. And it means using our existing service oriented architecture is impossible (without a big overhaul.)

    System.Data 的退出对开发者来说是一件大事与 VB6 中的打印机对象丢失到 vb.net 1.0 是一样的.什么在这种情况下更难理解是为什么有必要 -在 Metro 配置文件中重新启用它不可能是技术性的产品难度,可以吗?

    The withdrawal of System.Data is as big a thing for developers to deal with as the loss of the Printer object in VB6 to vb.net 1.0 was. What is harder to understand in this case is why it is necessary - re-enabling it in the Metro profile can't possibly be a technical difficulty of the product, can it?

    它足够有价值,我会认真考虑包括 Mono 的System.Data 类作为我创建的任何应用程序的一部分(这显然会必须是开源的.)

    It is valuable enough that I would seriously consider including Mono's System.Data classes as part of any app I create (which would obviously have to be open source.)

    这篇关于Windows 8 Metro 应用程序应如何连接到中央数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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