zoukankan      html  css  js  c++  java
  • LinQ In Action 学习第四章

    第四章开始了 LinQ to Object 的讲解(Entity 用了很多linq的语法,如果Linq 掌握好了Entity很好学了):

    第四第五章 需要多加练习例子,熟练linq 的语法。

    第四章的例子做完了,主要讲了一些常用的Linq 语法。

    1.select select many

    2. orderby 

    3. group, join group, left join, cross join, inner join, nested query

    4.where .......

     5. take() skip()

    写了几个小例子:

     var publishersource = from bookbb in books
                                       select new
                                       {
                                           Name = from pub in Publishers
                                                  where pub.Name == bookbb.Publisher.Name
                                                  select pub,
                                           bookbb.Title,
                                           bookbb.Price
                                       };
                 var groupsource = from groupbook in books
                                   group groupbook by groupbook.Publisher into PublisherGroupName
                                   select new { Name = PublisherGroupName.Key.Name, Books = PublisherGroupName };

                 var groupjoinsource = from publishersor in Publishers
                                  join booksor in books
                                  on publishersor equals booksor.Publisher into PublisherGroup
                                  select new { Name = publishersor.Name, Books = PublisherGroup };

                 var leftjoingroup = from publisher in Publishers
                                       join booksor in books
                                       on publisher equals booksor.Publisher into GroupPublisher
                                       from book in GroupPublisher.DefaultIfEmpty()
                                       select new { Publisher = publisher.Name,
                                                    Book = book == default(Book)?"no books":book.Title };
                 var crossingJoin = from publisher in Publishers
                                    from book in books
                                    select new
                                    {
                                        Name = publisher.Name,
                                        Title = book.Title
                                    };

    第五章主要讲性能:

    1. nongeneric collection need to : Cast, ofType,  explicitly convert to object.

    2.分组使用多个元素  group by more than one characters.

  • 相关阅读:
    自定义可下拉刷新列表
    在listview里面的checkbox被选中或取消
    [转]Android中音乐文件的信息详解【安卓源码解析二】
    service 和broadcastreceiver的简略小结
    闹铃
    hdu 2112赤裸裸的最短路
    hdu 2177错题,很水的测试数据
    hdu 2184模拟
    hdu1150最小点集覆盖
    hdu 3746KMP的应用
  • 原文地址:https://www.cnblogs.com/recordlife/p/4218771.html
Copyright © 2011-2022 走看看