I am writing a LINQ query similar to the following:
var test = from o in dbcontext.Orders.AsEnumerable()
where o.ID==1
select new Order
{
Name = GetName(o.ID)
};
In order to call an external function within the LINQ query, I am using AsEnumerable()
within the query.
I understand that normally the query is not executed until an enumeration function like ToList()
, etc. is called. But here I am calling the enumeration within the query.
Can anyone tell me if it is considered bad practice to use AsEnumerable()
like this? Will it suffer in performance compared to calling ToList()
after creating the query?