对于 Silverlight 应用程序中的数据存储来说,什么是一个好的、简单的解决方案?
我有一个在 IIS 上运行的 silverlight 应用程序,当前有一些数据列表硬编码到 c# 中,我知道这不是一个好主意,但这是为了概念验证演示,现在我需要继续从另一个源获取数据可以修改。
我查看了 xml 文件以及 sql 数据库。问题是客户端不愿意允许在机器上安装任何额外的东西(漫长的安全过程),因此 sql express 可能不实用。我也尝试过研究 sql 紧凑版,但我似乎无法找到任何关于它的像样的教程。
数据由三个相当短的小对象列表组成,其中包含字符串和整数。我正在寻找一种最好是简单且快速实施的解决方案,理想情况下不需要在服务器上安装任何额外内容。
有人有任何可能有用的建议或链接吗?
提前致谢
帽
I have a silverlight application running on an IIS which currently has some data lists hard coded into the c#, not a good idea I know but this was for a proof of concept demo and now I need to move on to getting the data from another source which can be modified.
I've looked at xml files as well as an sql database. The problem is that the client is reluctant to allow anything extra to be installed on the machine (long security process) and so sql express may not be practical. I've also tried to look into sql compact edition but I cannot seem to be able to find any decent tutorials about it.
The data is made up of three, fairly short, lists of small objects which contain strings and integers. I'm looking for a, preferably, simple and quick to implement solution which ideally does not need anything extra installing on the server.
Does anyone have any suggestions or links which may be handy?
Thanks in advance
Cap
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您习惯使用 LINQ 而不是 SQL 来查询数据,Sterling DB 听起来非常适合您。它非常轻量级,并且不需要服务器或客户端上的任何额外内容(显然除了将其包含在代码中之外)。它使用隔离存储来存储数据。所有序列化/反序列化都由库为您处理。
编辑:
根据您关于数据是“静态”的评论(意味着所有客户端都使用相同的数据),最好不要使用像 Sterling 这样的客户端数据库,甚至(正如您提到的)SQL CE。您对硬编码此类“目录”数据持保留态度是正确的,因为该数据的更改将需要新版本的软件。
进行抽象的一种简单方法是在包含所有数据的 XAP 旁边托管一个 XML 文件。您可以按照您想要的任何方式编写 XML。在软件中,下载 XML 文件、解析它并在每次应用程序运行时填充目录应该相当简单。当需要更改目录时,只需修改 XML 文件即可。
If you are comfortable using LINQ to query your data instead of SQL, Sterling DB sounds perfect for you. It's extremely lightweight, and requires nothing extra on the server or the client (other than including it in your code obviously). It uses isolated storage to store data. All of the serialization/deserialization is taken care of for you by the library.
Edit:
Based on your comment that the data is "static" (meaning all clients consume the same data), it's probably best not to use a client-side database like Sterling or even (as you mentioned) SQL CE. You are right to have reservations about hard-coding this type of "catalog" data, as changes in that data would require a new release of software.
A simple way to make the abstraction is to simply host an XML file alongside your XAP that contains all your data. You can author the XML in any way you want. In the software, it should be fairly straightforward to download the XML file, parse it, and populate your catalog each time the app runs. When changes to the catalog are necessary, it's just a matter of modifying the XML file.
我知道这不是一个理想的解决方案,但您可以尝试使用制表符分隔的文本文件。它们是最容易创建的。
I know this is not an ideal solution but you could try using tab separated text files. They are the easiest to create.
我使用 XML (web.config) 来存储所有客户端使用的数据,例如预配置或默认用户设置值,并使用 隔离存储,用于与客户端无关的数据,例如用户 UI 布局设置。
I use XML (web.config) to store data use by all clients such as pre-configure or default user setting value and use Isolated Storage for client-independent data, such as, user UI-layout setting.
我会将对象序列化为 XML 并将它们存储在服务器上,这相对容易做到
你可以将值拉入 XDocument
这是我正在使用的序列化函数
I would serialize the objects to XML and store them on the server, it's relatively easy to do
You can pull the values into and XDocument
Here are the serialization function i'm using