1

In web api the data without using .ToList() is also send to api, but how? This is my LINQ query and I do not use the .ToList() but my data is also sent to the browser.can anyone please tell me the difference or can describe that how it is working?

using (var _context = new iCMEFModelCon())
                {
                    return _context.UserResidents.Where(c => c.ResidentId == residentId)
                        .Select(c => new
                        {
                            UserId = c.User.Id,
                            UserName = ((c.User.FirstName ?? "") + " " + (c.User.LastName ?? "")).Trim()
                        });
                }
Ali Nafees
  • 67
  • 10

1 Answers1

1

The return type of the query is either IEnumerable or IQueryable:

The result of a Linq database query is typically IQueryable< T> which is derived from IEnumerable< T>, IQueryable, and IEnumerable.

If your data source is an IEnumerable, the result type isIEnumerable< T>

Find More

Sanjeev S
  • 626
  • 1
  • 8
  • 27