解析 XML 并将其存储在 SQL Server 数据库中的最佳实践
我正在使用一个解决方案,其中 http 处理程序接收 XML 块。这些块应该被解析并映射到 SQL Server 数据库模型中。
我见过一些通过存储过程完成解析的解决方案。对我来说,在应用程序层解析它然后将其插入数据库似乎是一个更好的解决方案。
这两种方法的优缺点是什么?
我应该在处理程序中进行解析还是应该异步完成?
I'm working with a solution in which a http handler receives chunks of XML. These chunks should be parsed and mapped into a SQL Server database model.
I've seen some solutions where the parsing is done via stored procedures. To me it seems like a better solution to parse it in the application layer and then insert it to the db.
What would be the pros and cons with these two approaches?
Should I do the parsing in the handler or should this be done asynchronously?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过几种方式来创建它。
1)(我更喜欢)创建C#解析器并使用批量插入将数据加载到数据库(http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.aspx)。此处示例 http://www.codeproject.com/KB/database/SqlBulkCopy.aspx。这种方法的主要优点是完全管理加载。
2) SQL Server 集成服务。主要优点是它的速度。
你应该思考你想要实现什么目标。如果您需要非常快地加载它,您应该使用 SSIS,如果您需要完美的灵活性和高级功能,请使用 C# 方法。
You can create do it by few ways.
1) (I'd prefer it) Create C# parser and load data to database using bulk insert (http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.aspx). Sample here http://www.codeproject.com/KB/database/SqlBulkCopy.aspx . The main advantage of this approach is full management of loading.
2) SQL Server Integration Services. The main advantage is its speed.
You should think what do you want to achive. If you need to load it really fast, you should use SSIS, if you need perfect flexibility and advanced features use C# approach.