XLinq 与 SqlDataReader 性能对比
作为尝试修复相当混乱的遗留系统中的内容的一部分,我有一个方法调用 SQLServer 数据库中的存储过程。这个设置中没有什么是理想的,但这是我必须处理的。我有两个选项,一个是使用 SqlDataReader 从数据库中读取流作为行,或者将响应作为 xml 块进行传递。尽管 xml 从未真正解决过任何问题(在此插入可爱的眨眼),但我倾向于选择该选项并使用 XLinq 从数据创建我的业务对象,仅仅是因为该解决方案看起来不像有人在屏幕上呕吐。 ;)
然而,我担心的是采用这种方法会引入性能问题。有这方面有经验的人可以帮助我吗? Xlinq 是否可能会进一步减慢我已经很慢的代码?
As a part of trying to repair stuff in a fairly messed up legacy system I have a method making a call to a stored procedure in our SQLServer database. Nothing in this set up is ideal, but it is what I have got to work with. The two options I have is to use a SqlDataReader to read the stream as rows from the database, or to be handed the response as a chunk of xml. Even though xml has never really solved anything (insert cute wink here), I am leaning toward choosing that option and using XLinq to create my business objects from the data, simply because that solution would look less like someone vomited on the screen. ;)
The thing I'm concerned about, however, is to introduce performance issues by taking this approach. Is there anyone out there with experience in this that can help me? Is Xlinq likely to slow my already slow code down further?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
就性能而言,SqlDataReader 是正确的选择。
Esteban Garcia 也做了一些基准测试本·霍德森。结果相当结论性,尽管它们不包括 XLinq。
Performance wise, SqlDataReader is the right choice.
Esteban Garcia has done some benchmarks as did Ben Hodson. The results are fairly conclusive, though they do not include XLinq.
您还可以使用 Linq To Datasets。这样您就可以使用 Linq API,并且无需更改 STP。然而,从性能角度来看,它不如 SqlDataReader。
You could also use Linq To Datasets. This way you can use the Linq API, and you don't have to alter your STP. Nevertheless, performancewise this is inferior to SqlDataReader.