将 FlowDocument 保存到 SQL Server [英] Saving FlowDocument to SQL Server
问题描述
我需要将 WPF FlowDocuments 保存到 SQL Server.这样做的最佳格式是什么?细绳?斑点?在不到 5K 字左右的文档中重要吗?
I need to save WPF FlowDocuments to SQL Server. What is the best format for doing that? String? Blob? Does it matter in a document less than 5K words or so?
推荐答案
如果只想将 FlowDocument 对象存储在数据库中,而不进行任何处理,我建议使用二进制序列化,并将生成的字节数组存储到 varbinary(最大限度).这速度很快,而且可以很好地扩展.
If you just want to store the FlowDocument objects in a database, without any processing, I would recommend using binary serialization, and storing the resulting byte array into a varbinary(max). This is fast and scales well.
但是,如果您已经将 FlowDocuments 作为 XML 文件,那么将它们转储到 nvarchar(max) 字段会更容易,没有(添加)序列化/反序列化开销.对于低于 8k 的值,这可以轻松扩展,然后执行还可以,直到达到 10MB 左右.
However, if you already have the FlowDocuments as XML files, than it would be easier just to dump them into a nvarchar(max) field, with no (added) serialization/deserialization overhead. This scales trivially for values under 8k, and then performs kinda OK until you hit around the 10MB mark.
这篇关于将 FlowDocument 保存到 SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!