Linq to sql LET statement

Can the "let" statement be used to create joins in linq to sql or just temporary variable. For example here :

var r =
            from cust in Cust.GetTable()  
            let invs = cust.InvoiceDetails        
            let jobs = cust.Jobs
           
            select new
           {
     .
     .
     .
             };
simshpAsked:
Who is Participating?
 
Fernando SotoConnect With a Mentor RetiredCommented:
Hi simshp;

To answer your question,

Can the "let" statement be used to create joins in linq to sql or just temporary variable

A temporary variable in Linq is called a Range variable and that is all it can be used for, to hold a value from some calculation or even the results of another query which would be called a sub-query.

Fernando
0
 
jeebukarthikeyanCommented:
hi,


try this way

var q = from c in Customer.AllCustomers
        [b]let [/b]customerId = c.CustomerID
        select new Customer() { CustomerID = customerId, CompanyName = c.CompanyName,
                    ContactName = c.ContactName, ContactTitle = c.ContactTitle,
                    Address = c.Address, City = c.City, Country = c.Country };

Open in new window



0
 
käµfm³d 👽Commented:
Can you expand? I don't see where you are trying to do a join in the above example.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
simshpAuthor Commented:
Thanks .. I am just asking a factual question ... I am new to linq - so the from the code I posted, are the let stmts just assigning a column value to a variable. Like

let invs = cust.InvoiceDetails

simply places the all the columns values into the variable invs ?
0
 
jeebukarthikeyanCommented:
hi,

have a look @ below link

linq


jeebu
0
 
simshpAuthor Commented:
Thanks
0
 
Fernando SotoRetiredCommented:
Not a problem, just glad to help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.