In my query i need to return IEnumerable but i dont know if this action make the query to execute again?
var data = Repository<Person>.Find().AsEnumerable();
Find() returns IQueryable and because IQueryable inherits IEnumerable. I doubt if AsEnumerable make the repetitive execution.
I know that
var data = Repository<Person>.Find().ToList() executes the query two times. One for Find() and second for Tolist()
An
IQueryableis anIEnumerable. There is no conversion, and therefore no work of any kind going on.The work happens when you call
GetEnumerator(), either explicitly or by invokingforeachon it.Also, have you confirmed that
Repository.Find().ToList()calls SQL twice? That doesn’t sound right to me.