Reputation: 50
Ok I have been searching for a day and a half with no luck. I have a simple Microsoft SQL database and I want to pull two rows from then display it in a view. What I have tried so far was
public IEnumerable<Char> FindAllUsers()
{
var t = db.Users.SelectMany(c => c.FirstName).ToList();
List<Char> list = t;
return list;
}
I have also tried
IEnumerable<User> name = db.Users
.Select(FirstName => FirstName)
.ToList();
return name;
List<User> name = db.Users
.Select(FirstName => FirstName)
.ToList();
With no luck. I feel that I am not going about this the right way. Any help would be appreciated.
Upvotes: 0
Views: 56
Reputation: 9881
Building up on Murali's answer, if you just want the names:
var allUserNames = (from u in db.Users select u.FirstName);
Upvotes: 1