About IEnumerable<T> isn't an enough reason to prove what you said, here's my demo:
public class A{public int Number{get;set;}}
//Sample db contents
List<A> a = new List<A> { new A { Number = 1 }, new A { Number = 2 } };
//Fetch an interface
IEnumerable<A> r = from i in a select i;
//Change number
r.First().Number = 2;
Console.WriteLine(a[0].Number);
TimoYang
Contributor
3732 Points
1275 Posts
Re: Why it cannot work property without "ToList"?
Jun 04, 2012 07:49 AM|LINK
PS:A very nice tool to see the source codes of .net framework for you, you can see:
http://wiki.sharpdevelop.net/ILSpy.ashx
:-)
And then tell me why?
Thxxxxxxxxxxxxxxxxxxx
TimoYang
Contributor
3732 Points
1275 Posts
Re: Why it cannot work property without "ToList"?
Jun 04, 2012 07:59 AM|LINK
About IEnumerable<T> isn't an enough reason to prove what you said, here's my demo:
public class A{public int Number{get;set;}}
//Sample db contents List<A> a = new List<A> { new A { Number = 1 }, new A { Number = 2 } }; //Fetch an interface IEnumerable<A> r = from i in a select i; //Change number r.First().Number = 2; Console.WriteLine(a[0].Number);Guess what's the number of "a[0]"?
Ah hahaha……
I don't know why?!
:(