In SQL, one should always strive for set-based operations versus iteration-based (i.e. looping). In .NET, we frequently loop collections and objects. Are there any commands in .NET that allow set-based processing or is everything iteration-based? (I'm reminded of how DataAdapter.Fill
calls DataReader
which iterates through each record in the result set). I'm not terribly familiar with LINQ
, but my guess would be that its implementation merely masks the iterations happening behind the scenes.
UPDATE:
To clarify: I'm not claiming to be any sort of genius here and I'm not second guessing any of the brilliant people who make my life programming better. I am simply asking if there are commands that perform set-based operations, like SQL does when you UPDATE
, versus foreach(var item in obj) { ... }
which is clearly iterating through the object. SQL developers are chastised at every turn if ever they use a loop, yet in .NET, we use them all the time. Being a develper who works heavily in both SQL and .NET, I'm asking if there are any alternatives in .NET that avoid looping altogether.