Steveluo’s Blog

Just another weblog

Archive for July, 2009

What a advanced C# developer should know

Posted by steveluo on July 19, 2009

3. “What Great .NET Developers Ought To Know”,


Posted in Uncategorized | Leave a Comment »

Linq(2) to DataTable

Posted by steveluo on July 19, 2009

Generally we need get an  initial dataset  from Database by Sql   and then use  linq to filter it again to serve different purposes.   the article show how to create a tableView based on linq:

  • EnumerableRowCollection query   
  •               = from customer in dtCustomer.AsEnumerable()   
  •                 where customer.Field(“State”) == “NJ”  
  •                 select customer;   
  •             DataView njview = query.AsDataView();  

    the chapter Chapter 14 in LinQ in Action gives us the details.  and Other examples on the web and Linq to DataTable  example1 

  • Points to understand Linq:  (from Joseph Rattz’s book)
    1)  linq, a query,  returnes set of objects is called a sequence.  Most linq sequences are of type IEnumerable<T>
    2)  a lambda expression in C# with format:   
    (param1, param2, …paramN) => expr
    (param1, param2, …paramN) =>   {   statement1; statement2; … statementN; return(lambda_expression_return_type); }
    x => x.Length > 0   could be read as   “input x returns x.Length > 0.”

    Linq Wiki
    get data from Excel by linq




    Posted in Uncategorized | Leave a Comment »