I\'m building a Web API project that will be made available to third-party\'s and also used by my own web application/s. The Web API methods will return JSON representations
The complete method could be:
public List Get()
{
using (var db = new MyContext())
{
return (from u in db.Users
orderby u.FirstName
select new User()
{
Id = u.pkUser,
Username = u.Username,
Password = u.Password,
Active = u.Active
}).ToList();
}
}
You said you want the result "without iteration". Using LINQ also does not eliminate the iteration. You are not doing it in your code, but it really happens when you call the ToList()
method.