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
}


本文转自BloodyAngel博客园博客,原文链接:http://www.cnblogs.com/zgynhqf/archive/2009/11/21/1607710.html,如需转载请自行联系原作者

相关文章
|
3月前
|
开发框架 自然语言处理 .NET
C#一分钟浅谈:LINQ 查询表达式的使用技巧
【9月更文挑战第6天】LINQ(Language Integrated Query)是C#开发中的强大工具,使查询数据集合变得简单且接近自然语言。本文从基础入手,通过具体示例讲解LINQ查询表达式的使用技巧,包括过滤、排序和分组等操作。同时,文章还探讨了常见问题及解决方法,如性能优化、过早枚举和类型转换等,帮助开发者写出更高效、易维护的代码。
104 15
|
XML SQL 开发框架
LINQ初步
C#中的LINQ入门学习
71 0
|
开发框架 .NET
2.3 LINQ
.net core LINQ
|
开发框架 .NET Serverless
C# Linq语言集成查询
C# Linq语言集成查询