通过不缓存结果的方式实现LINQ有什么好处?
对于使用LINQ弄湿脚的人来说,这是一个众所周知的陷阱: public class Program { public static void Main() { IEnumerable<Record> originalCollection = GenerateRecords(new[] {"Jesse"}); var newCollection = new List<Record>(originalCollection); Console.WriteLine(ContainTheSameSingleObject(originalCollection, newCollection)); } private static IEnumerable<Record> GenerateRecords(string[] listOfNames) { return listOfNames.Select(x => new Record(Guid.NewGuid(), x)); } private static bool ContainTheSameSingleObject(IEnumerable<Record> originalCollection, List<Record> newCollection) { return originalCollection.Count() == 1 && newCollection.Count() …