Entity Frameworkの - LINQのエンティティへの使用

1.プロジェクション
ContractedBlock.gif ExpandedBlockStart.gif コード
使用(VARのCTX = 新しい SchoolEntities())
{
    のObjectQuery
< コース>  コース  =  ctx.Courses。
    IQueryable
< コース>  allcourses  =  Cから   コースを
                                     選択し、C。
    Console.WriteLineを(courses.ToTraceString())。
}
2.どこ
ContractedBlock.gif ExpandedBlockStart.gif コード
使用(VARのCTX = 新しい SchoolEntities())
{
    のObjectQuery
< コース>  コース  =  ctx.Courses。
    IQueryable
< コース>  allcourses  =  Cから   コース
                                     
 c.CourseNameが  == " 法律"                                      Cを選択します。} 


3.Pagination
ContractedBlock.gif ExpandedBlockStart.gif コード
使用(VARのCTX = 新しい SchoolEntities())
{
    のObjectQuery
< コース>  コース  =  ctx.Courses。
    IQueryable
< コース>  allcourses  =  Cからの   コース
                                     c.CourseTypeはORDERBY
                                     c.Skip(選択
0 ).Take(100 )。
}
4.集計(平均、MAX、MIN、カウント、合計)
使用 (VARのCTX = 新しい  SchoolEntities())
{
    古いVAR 
=  ctx.Persons.Max(P => p.Age)。
    Console.WriteLineを(older.Value)。
}
5.参加
使用 (VARのCTX = 新しい  SchoolEntities())
{
    VARクエリ 
=  からC   ctx.Coursesは
                Dに参加 
 ctx.CourseDetails
                d.CourseIDにはc.CourseIDに等しい
                選択 
新しい {
                    C、d.Infoを}。
}

ます。https://www.cnblogs.com/crossingdawn/archive/2009/07/27/1532212.htmlで再現

おすすめ

転載: blog.csdn.net/weixin_33874713/article/details/93409757