ToList() or not to List.
-
I notice that VS Intellisense wants to tag every LINQ query I code with ".ToList()". It is in fact an extra step that imposes unnecessary overhead when all you need is an IEnumerable in the chain. It just gets worse as the "frame rate" increases. While List<> is prefered "internally", it doesn't pay to be reflex "converting" when it isn't necessary. (IMO)
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
-
I notice that VS Intellisense wants to tag every LINQ query I code with ".ToList()". It is in fact an extra step that imposes unnecessary overhead when all you need is an IEnumerable in the chain. It just gets worse as the "frame rate" increases. While List<> is prefered "internally", it doesn't pay to be reflex "converting" when it isn't necessary. (IMO)
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
It doesn't "want" to append it. It's just that the "AI" has seen it so much in all of the code in its training repositories that it thinks that's what is most likely to come next.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak
-
It doesn't "want" to append it. It's just that the "AI" has seen it so much in all of the code in its training repositories that it thinks that's what is most likely to come next.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak
I doesn't "want" to but can't help itself? Caught up in the herd mentality? And that makes it "OK"?
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
-
I doesn't "want" to but can't help itself? Caught up in the herd mentality? And that makes it "OK"?
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
An AI in only as good as the training set it's taught with, so yeah, you could say it's following the heard. I never said that makes it "OK". All I said is what it's doing.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak
-
I notice that VS Intellisense wants to tag every LINQ query I code with ".ToList()". It is in fact an extra step that imposes unnecessary overhead when all you need is an IEnumerable in the chain. It just gets worse as the "frame rate" increases. While List<> is prefered "internally", it doesn't pay to be reflex "converting" when it isn't necessary. (IMO)
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
-
I notice that VS Intellisense wants to tag every LINQ query I code with ".ToList()". It is in fact an extra step that imposes unnecessary overhead when all you need is an IEnumerable in the chain. It just gets worse as the "frame rate" increases. While List<> is prefered "internally", it doesn't pay to be reflex "converting" when it isn't necessary. (IMO)
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
It really depends what I want to do with the list. I'll leave it as an enumerable until the point I want to do more than one thing with it. Suppose I wanted to check to see if the list had something in it before I started processing in it - the fact that I'm going to be calling Any and foreach (for example), suggests to me that I should materialise the enumerable and then act on it. If I don't, I'm just going to end up materialising it twice under the covers.
-
I doesn't "want" to but can't help itself? Caught up in the herd mentality? And that makes it "OK"?
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
lol. Yep. I have certainly seen developers do that. They can't figure out how to do it in the initial clause so they end up processing it in memory. Definitely not a good thing for working with a database. Sigh...unfortunately I have also seen this happen implicitly by the library. I can see it by profiling in SQL Server while running a linq expression. That makes everything horribly wrong. It means I have no way to verify except by profiling everything. I have seen all of the following by profiling. - It dragged the entire table into the app space and then applied the clauses. - It did an in clause by doing a while loop over each in parameter. So 200 separate SQL calls. - It did a join by doing a different SQL call for each table and then joining in memory. None of the above makes me want to ever use linq again.