• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 921
  • Last Modified:

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
           {
     .
     .
     .
             };
0
simshp
Asked:
simshp
  • 2
  • 2
  • 2
  • +1
1 Solution
 
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
 
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
Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

 
jeebukarthikeyanCommented:
hi,

have a look @ below link

linq


jeebu
0
 
Fernando SotoCommented:
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
 
simshpAuthor Commented:
Thanks
0
 
Fernando SotoCommented:
Not a problem, just glad to help.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now