KamRon
KamRon

Reputation: 50

Pulling all rows from database then displaying them to a table

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

Answers (2)

Andy T
Andy T

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

Murali Murugesan
Murali Murugesan

Reputation: 22619

Try to use

 var allUser= (from u in db.Users select u);

Upvotes: 1

Related Questions