开发者

How to Cache Ienumerable var

开发者 https://www.devze.com 2022-12-22 09:30 出处:网络
I have the following code : XDocument xR开发者_高级运维esponse = XDocument.Parse(strXMLResponse);

I have the following code :

XDocument xR开发者_高级运维esponse = XDocument.Parse(strXMLResponse);

var vMyData = from xmyInfo in xResponse.Descendants("Result").Elements("item")
select new myProporties
{
      strmyInfo1 = ((string)xmyInfo .Element("el1")).Trim(),
      strmyInfo2 = ((string)xmyInfo .Element("el2")).Trim(),
      strmyInfo3 = (string)xAudioinfo.Element("el3")
};

Now I want to cache the vMyData having dependency on strXMLResponse.

Thanks


vMyData = vMyData.ToList();

This will enumerate your IEnumerable and capture the result into a List<T> (which is then idempotent).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号