LINQtoSQL: Query to return List<String>

Posted by ctrlShiftBryan on Stack Overflow See other posts from Stack Overflow or by ctrlShiftBryan
Published on 2010-03-23T18:29:06Z Indexed on 2010/03/23 18:33 UTC
Read the original article Hit count: 293

Filed under:
|

I have a LINQ query that returns some object like this...

var query = from c in db.Customers
            where ...
            select c;

Then I do this

    List<String> list = new List<String>();
    foreach (ProgramLanguage c in query)
    {
        //GetUL returns a String
        list.Add(GetUL(c.Property,c.Property2));
    }

Is there a way to combine into something list this?

var query = from c in db.Customers
        where ...
         select new
         {
            GetUL(c.Property,c.Property2)
         }).ToList<String>();

© Stack Overflow or respective owner

Related posts about linq-to-sql

Related posts about tolist