Say I have the following code (context narrow to keep the detail of the question narrow)
code > Public stable IEnumerable & lt; Color & gt; GetThemColors () {var ID = GetThePrimaryIds (); Foreign Currency ID (ID) {yield yield GetColorById (ID); } ID = GetTheOtherIds (); Foreign exchange (iid in iid) {yield yields return on callersbid ID; }}
I would like to rewrite them to do something (which does not compile the offer)
public static IEnumerable & lt; Color & GetTheMColors () {GetThePrimaryIds () Select (ID => yield returns GetColorById (ID)); GetTheOtherIds (). (ID => yield returns GetOtherColorsById (ID));}
< / Pre>The key point is that in my first snippet I have two foreach enumerators, which I do not know how to do in linq without losing my lazy-loading features.
you want
concat
:return GetThePrimaryIds ( ) Select (ID => GetColorById (ID)> GetTheOtherIds. (ID = & gt; GetOtherColorsById (ID));
Also keep in mind that you < Code> yield returns is not required.
No comments:
Post a Comment