see the below example and tell me why they use .AsEnumerable() before select ?
they could use select directly.....is not it?
tell me the intention of usage of .AsEnumerable() here in below query?
why they use .ToArray(); instead of Tolist() ?
they could use select directly.....is not it?
tell me the intention of usage of .AsEnumerable() here in below query?
why they use .ToArray(); instead of Tolist() ?
private IEnumerable<AutoCompleteData> GetAutoCompleteData(string searchTerm)
{using (var context = new AdventureWorksEntities())
{var results = context.Products
.Include("ProductSubcategory")
.Where(p => p.Name.Contains(searchTerm)&& p.DiscontinuedDate == null)
.AsEnumerable()
.Select(p =>new AutoCompleteData
{
Id = p.ProductID,
Text = BuildAutoCompleteText(p)
})
.ToArray();return results;
}
}