I have to do conditional joining between two tables Price and Operator
Table Prices
- CustomerName
- UnitPrice
- Country
- Code
Table Operators
- OpertorName
- Country
- Code
Joining requires to be run on following two conditions:
a. If Code is null for a record in table Prices then join only on basis of Country (all Codes of selected Country will be included from table Operators)
b. If Code is present for a record in table Prices then join on basis of both Country and Code
Please help
//If Code is null in table Price for a record then :
var reportList = (from pl in Prices
join ml in Operators
on pl.Country equals ml.Country
select new PriceReports { }
//If Code is present in table Price for a record then
var reportList = (from pl in Prices
join ml in Operators
on new { a = pl.Country, b = pl.MNC } equals new { a = ml.Country, b = ml.Code }
select new PriceReports { }
I want to create a single query to represent both above conditions