Using LINK How do you Select All from a Table?

Posted on 2011-10-31
Medium Priority
Last Modified: 2012-05-12
Using LINK with C# how do you select everything from a table and put it into a List?


Question by:danielolorenz
  • 2
LVL 16

Expert Comment

by:Easwaran Paramasivam
ID: 37060713
Create a class contains all column of the table as properties say for ex tableclass. Use below query to select all column to List.

List<tableclass> myList = from alias in table
                                         select alias;

LVL 16

Accepted Solution

Easwaran Paramasivam earned 2000 total points
ID: 37060721
Sorry for the inconvienience. Directly the list could not be get from the table. Use var to store the result then add each entry to the list as given below.

List<tableclass> MyList = new List<tableclass>();

var query =  from alias in table
              select alias;

foreach (var result in query)

Open in new window


Author Closing Comment

ID: 37069988
Thanks for your help

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Integration Management Part 2
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question