Link to home
Start Free TrialLog in
Avatar of simshp
simshpFlag for Israel

asked on

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
           {
     .
     .
     .
             };
Avatar of jeebukarthikeyan
jeebukarthikeyan
Flag of India image

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



Avatar of kaufmed
Can you expand? I don't see where you are trying to do a join in the above example.
Avatar of simshp

ASKER

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 ?
hi,

have a look @ below link

linq


jeebu
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of simshp

ASKER

Thanks
Not a problem, just glad to help.