14

在桌面 .NET 应用程序中,实现本地关系数据库的标准选项是使用 SQL Server Compact Edition,当然也可以使用 SQLite 和其他第三方引擎。

.NET Metro 风格的应用程序有哪些可用的选项?SQL CE 似乎不可用 - 任何替代品?事实上,整个System.Data命名空间似乎都消失了——所以也没有 LINQ to SQL 或实体框架?

似乎对 Metro HTML/JS 应用程序可用的 HTML5 IndexedDB 怎么样 - 可以从 .NET 以某种方式使用吗?

4

2 回答 2

1

显然,Metro 应用程序中仍然可以使用可扩展存储引擎Win32 API(又名“JET Blue”)。C++ 可以直接通过#include <esent.h>. .NET 应用程序必须使用 P/Invoke。这并没有提供 SQL 或任何其他类型的高级关系查询构造,但它确实提供了键查找、事务、每个表的多个索引和多字段索引。

于 2011-09-19T06:12:31.983 回答
0

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.

于 2011-10-05T15:10:52.810 回答