090706 T Linq 的认识

/// <summary>
/// 一个不错的Linq问题
/// </summary>
private void LinqQuestion()
{
    JZDataContext db = new JZDataContext();
    TextWriter log = new StringWriter();
    db.Log = log;

    IEnumerable<A_User> table = db.A_Users;
    var q2 = table.Where(u => u.Id == 1);
    var users1 = q2.ToArray();
    Response.Write(log.ToString());
    //SELECT [t0].[Id], [t0].[HeadImagePath], [t0].[Gender], [t0].[DomainName], [t0].[ThemeNo], [t0].[SLOB_XML], [t0].[RealName], [t0].[Birthday], [t0].[StudyLevel], [t0].[SelfComment], [t0].[SidelineExperience], [t0].[SidelinesWantToDo], [t0].[SidelineTime], [t0].[SidelineCities], [t0].[MoneyWant], [t0].[Race], [t0].[Speciality], [t0].[HasGraduated], [t0].[CollegeId]
    //FROM [dbo].[A_Users] AS [t0]
    //-- Context: SqlProvider(Sql2000) Model: AttributedMetaModel Build: 3.5.30729.1

    log = new StringWriter();
    db.Log = log;
    var q = db.A_Users.Where(u => u.Id == 1);
    var users2 = q.ToArray();
    Response.Write(log.ToString());
    //SELECT [t0].[Id], [t0].[HeadImagePath], [t0].[Gender], [t0].[DomainName], [t0].[ThemeNo], [t0].[SLOB_XML], [t0].[RealName], [t0].[Birthday], [t0].[StudyLevel], [t0].[SelfComment], [t0].[SidelineExperience], [t0].[SidelinesWantToDo], [t0].[SidelineTime], [t0].[SidelineCities], [t0].[MoneyWant], [t0].[Race], [t0].[Speciality], [t0].[HasGraduated], [t0].[CollegeId]
    //FROM [dbo].[A_Users] AS [t0]
    //WHERE [t0].[Id] = @p0
    //-- @p0: Input Int (Size = 0; Prec = 0; Scale = 0) [1]
    //-- Context: SqlProvider(Sql2000) Model: AttributedMetaModel Build: 3.5.30729.1
}

posted @ 2009-11-21 20:02  BloodyAngel  阅读(176)  评论(0编辑  收藏  举报