Mike Eghtebas
asked on
LINQ, WHERE clause issue
Question: Why lines 5 and 6 giving me trouble?
How can I fix this. I have used this sort of syntax for years in SQL work. What is the equivalent in LINQ (vb.net)?
Please see: http://developwith.net/2012/07/20/where-if-and-where-iif-linq/ if it could help. I may need some help in its implementation.
How can I fix this. I have used this sort of syntax for years in SQL work. What is the equivalent in LINQ (vb.net)?
Dim ODs = (From od In db.tblOrderDetails Join o In _
db.tblOrders On od.OrderID Equals o.OrderID Join c In _
db.tblCustomers On o.CustomerID Equals c.CustomerID Join s In _
db.tblSoftwares On od.SoftwareID Equals s.SoftwareID _
Where o.OrderID = IIf(intOrderID = 0, o.OrderID, intOrderID) And _
o.CustomerID = IIf(intCustID = 0, o.CustomerID, intCustID) _
Order By c.FirstName & " " & c.LastName _
Select CustName = c.FirstName & " " & c.LastName, _
od.OrderID, o.OrderDate, s.Title, od.Quantity, s.UnitPrice, Sub_Total = od.Quantity * s.UnitPrice).ToArray()
Please see: http://developwith.net/2012/07/20/where-if-and-where-iif-linq/ if it could help. I may need some help in its implementation.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What is the error?
ASKER
kaufmed,
My apology for not responding earlier. It didn't like IIF() syntax. I do not recall exact description. I have revised the solution since. But later I will try the solution from louisfr which seems a working solution.
Thanks,
Mike
My apology for not responding earlier. It didn't like IIF() syntax. I do not recall exact description. I have revised the solution since. But later I will try the solution from louisfr which seems a working solution.
Thanks,
Mike