Using LINK How do you Select All from a Table?

Posted on 2011-10-31
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
    LVL 16

    Expert Comment

    by:Easwaran Paramasivam
    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

    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

    Thanks for your help

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now