C# IEnumerator/yield structure potentially bad?

前端 未结 11 1290
面向向阳花
面向向阳花 2021-02-01 02:47

Background: I\'ve got a bunch of strings that I\'m getting from a database, and I want to return them. Traditionally, it would be something like this:

public Li         


        
11条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-01 03:32

    No, you are on the right path... the yield will lock the reader... you can test it doing another database call while calling the IEnumerable

提交回复
热议问题