Entity Framework -- Linq To Entity使用方式

1. Projection
Code
2. Where
Code
3.Pagination
Code
4. Aggregation (Average, Max, Min, Count, Sum)
using(var ctx=new SchoolEntities())
{
    var older 
= ctx.Persons.Max(p=>p.Age);
    Console.WriteLine(older.Value);
}
5. Join
using(var ctx=new SchoolEntities())
{
    var query 
= from c in ctx.Courses
                join d 
in ctx.CourseDetails
                on d.CourseID equals c.CourseID
                select 
new{
                    c, d.Info};
}
posted @ 2009-07-27 16:49  Crossing Dawn  阅读(311)  评论(1编辑  收藏  举报