Win8 Metro风格应用程序中结构化数据的本地存储
在桌面.NET应用程序中,实现本地关系数据库的标准选项是使用SQL Server Compact Edition,当然也可以使用SQLite和其他第三方引擎。
.NET Metro 风格应用程序有哪些可用选项? SQL CE 似乎不可用 - 有替代品吗?事实上,整个 System.Data 命名空间似乎都消失了 - 所以也没有 LINQ to SQL 或实体框架?
似乎可用于 Metro HTML/JS 应用程序的 HTML5 IndexedDB 怎么样?可以以某种方式从 .NET 使用它吗?
In a desktop .NET application, the standard option for implementing a local relational database is to use SQL Server Compact Edition, and then of course there is the possibility to use SQLite and other third-party engines.
What are the options available to a .NET Metro-style application? SQL CE seems to be unavailable - any replacement? In fact, the entire System.Data
namespace seems to be gone - so no LINQ to SQL or Entity Framework, either?
What about HTML5 IndexedDB that seems to be available to Metro HTML/JS apps - can that be used from .NET somehow?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
显然,可扩展存储引擎 Win32 API(又名“JET Blue”)在 Metro 应用程序中仍然可用。 C++ 可以直接通过
#include
使用它。 .NET 应用程序必须使用 P/Invoke。这并没有提供 SQL 或任何其他类型的高级关系查询构造,但它确实提供了键查找、事务、每个表的多个索引和多字段索引。Apparently, the Extensible Storage Engine Win32 API (aka "JET Blue") is still available in Metro apps. C++ ones can use it directly via
#include <esent.h>
. .NET apps would have to use P/Invoke. This does not give SQL or any other sort of high-level relational querying constructs, but it does provide for key lookup, transactions, multiple indices per table, and multi-field indices.让我们明确一点:SQL CE 存在于 Windows 8 中。它不仅存在于 Program Files 中,而且存在于 Windows\System32 中,看起来比以前更加嵌入式。 Windows7 在 system32 中没有 sqlcecompact40.dll,所以这绝对是新的。 System.Data 和 System.Data.Linq 都位于 C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5 中。
您可以手动添加对这些 dll 的引用,但要编译应用程序却很困难。看起来,如果您首先打开项目并且不执行任何操作,则可以在任何地方添加对这些 dll 的引用并编译应用程序。如果您删除 dll 并尝试将它们添加回来,您会遇到“对 '<4.5 框架目录> 的引用”如果您无法通过 Visual Studio 添加它们,您可以轻松地手动添加 HintPath,
但我也遇到了链接 AppX 无法正常工作的问题。一个神秘的“有效负载不能包含 2 个相同的 dll”类型的消息,就像它在最后一刻试图包含 32 位(我链接的那个)和 64 位一样,它包含了我没有手动接触的 DLL。 System.Data.OracleClient 或 System.Transactions 所以这绝对是我还没有再次看到的构建过程中的一些工件
我现在处理的主要问题是如何生成正确的连接字符串,因为它不会。 SQL CE 可能仍在寻找硬编码的 C:\ 引用,因此 ApplicationData 示例可能无法按需要正常工作,我可能会尝试在 Win7 中创建 SQL CE 4 数据库,然后转移到 Win8 并在本地引用它们。我在同一条船上此 | 关闭!
请随时评论您遇到的任何问题,如果有人想共享资源,我绝对愿意进行一些离线合作。这绝对是一片野兽茂密的森林,独自行动更具挑战性。
Let's be clear: SQL CE exists in Windows 8. It exists not only in Program Files but in Windows\System32 to seem even more embedded than before. Windows7 doesn't have sqlcecompact40.dll in system32 so this is definitely new. System.Data and System.Data.Linq both live in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.
You can add references to those dlls manually but getting the app to compile is hit or miss. It seems that if you first open your project and do nothing, you can add a reference to those dlls anywhere and compile the app. If you remove the dlls and try to add them back you're hit with a "A reference to '<4.5 framework directory>' could not be added. If by some chance you can't add them via Visual Studio you can easily just add the HintPath manually.
My app now compiles but I also ran into an issue where linking the AppX wasn't working correctly and it gave a cryptic "Payload cannot contain 2 of the same dll" type messages. Like it was trying to include both 32 bit (the one I linked) and 64bit at the last minute. It included DLLs I wasn't touching manually like System.Data.OracleClient or System.Transactions so it was definitely some artifact from the build process I've yet to see again.
The main issue I'm dealing with right now is how to generate a proper connection string since it won't initialize properly without one. SQL CE is likely still looking for hardcoded C:\ references so the ApplicationData samples may not work as desired. I may try to make SQL CE 4 databases in Win7, transfer to Win8 and simply reference them locally but I'm kind of in the same boat there too. This | | close!
Please feel free to comment regarding any issues you run into and I'm definitely down for some offline collaboration if anyone would like to pool resources. This is definitely a thick forest of beasts and going it alone is proving a lot more challenging.