090706 T Linq 的认识

2018-01-26 10:50:48 浏览数 (2)

代码语言:js复制
/// <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
}

0 人点赞