第四章开始了 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.