LINQ: Dot Notation vs Query Expression
        Posted  
        
            by Martín Marconcini
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Martín Marconcini
        
        
        
        Published on 2009-03-10T13:01:03Z
        Indexed on 
            2010/03/17
            9:21 UTC
        
        
        Read the original article
        Hit count: 403
        
I am beginning to use LINQ in general (so far toXML and toSQL). I've seen that sometimes there are two or more ways to achieve the same results. Take this simple example, as far as I understand both return exactly the same thing:
SomeDataContext dc = new SomeDataContext();
var queue = from q in dc.SomeTable
        where q.SomeDate <= DateTime.Now && q.Locked != true
        orderby (q.Priority, q.TimeCreated)
        select q;
var queue2 = dc.SomeTable
        .Where( q => q.SomeDate <= DateTime.Now && q.Locked != true )
        .OrderBy(q => q.Priority)
        .ThenBy(q => q.TimeCreated);
Besides any mistake I may have made in the syntax or a missing parameter or difference, the idea is that there are two ways to express the same thing; I understand that the first method has some limitations and that the "dot notation" is more complete, but besides that, are there any other advantages?
© Stack Overflow or respective owner