C#:除了 DataSet 你还用什么还用、DataSet

2023-09-06 04:55:51 作者:白头偕老不是说说而已

我发现自己对 .Net 中的 DataSet/DataTable/DataRow 范式越来越不满意,主要是因为它通常比我真正想做的要复杂几个步骤.在我绑定到控件的情况下,DataSet 很好.但在其他情况下,似乎有相当多的精神开销.

I've found myself increasingly unsatisfied with the DataSet/DataTable/DataRow paradigm in .Net, mostly because it's often a couple of steps more complicated than what I really want to do. In cases where I'm binding to controls, DataSets are fine. But in other cases, there seems to be a fair amount of mental overhead.

我玩过一些 SqlDataReader,这似乎对通过选择进行简单的短途旅行很有用,但我觉得 .Net 中可能还有一些其他模型对了解更多信息很有用.我觉得我在这方面找到的所有帮助都默认使用 DataSet.也许那和 DataReader 真的是最好的选择.

I've played a bit with SqlDataReader, and that seems to be good for simple jaunts through a select, but I feel like there may be some other models lurking in .Net that are useful to learn more about. I feel like all of the help I find on this just uses DataSet by default. Maybe that and DataReader really are the best options.

我不是在寻找最好/最差的细分,只是想知道我的选择是什么以及您对它们的体验.谢谢!

I'm not looking for a best/worst breakdown, just curious what my options are and what experiences you've had with them. Thanks!

-埃里克·斯普尔

推荐答案

自从 .NET 3.5 出来后,我就一直用 LINQ.真的那么好;我看不出有任何理由再使用那些旧拐杖了.

Since .NET 3.5 came out, I've exclusively used LINQ. It's really that good; I don't see any reason to use any of those old crutches any more.

尽管 LINQ 很出色,但我认为任何 ORM 系统都可以让您摆脱这些麻烦.

As great as LINQ is, though, I think any ORM system would allow you to do away with that dreck.