The key points when joining on multiple columns are:
The column types must be the same, and
The column names must also be the same.
The above query has been tested and works OK with the following mock-up:
Class mock-up resembling the SQL Schema:
<pre lang="cs">class Challan_Total
{
public int Id {get; set;}
public string Challan_No {get; set;}
public string Type {get; set;}
}
class Challan
{
public int Id { get; set; }
public string Challan_No {get; set;}
public string Own_Comany {get; set;}
public string Parti_Name {get; set;}
}
class Rate
{
public string Company_Id {get; set;}
public string Parti_Id {get; set;}
public string Meterial_type { get; set;}
public string Rate1 { get; set; }
}
Sample data:
List<Challan_Total> lstChallanTotal = new List<Challan_Total>()
{
new Challan_Total { Challan_No = "1", Id = 1, Type = "1"},
new Challan_Total { Challan_No = "2", Id = 1, Type = "1"},
new Challan_Total { Challan_No = "3", Id = 2, Type = "2"}
};
List<Challan> lstChallan = new List<Challan>()
{
new Challan { Id = 1, Challan_No = "1", Own_Comany = "1", Parti_Name = "1"},
new Challan { Id = 2, Challan_No = "2", Own_Comany = "1", Parti_Name = "2"},
new Challan { Id = 3, Challan_No = "3", Own_Comany = "3", Parti_Name = "3"}
};
List<Rate> lstRate = new List<Rate>()
{
new Rate { Company_Id = "1", Parti_Id = "1", Meterial_type = "1", Rate1 = "p1"},
new Rate { Company_Id = "2", Parti_Id = "1", Meterial_type = "1", Rate1 = "p2" },
new Rate { Company_Id = "3", Parti_Id = "2", Meterial_type = "2", Rate1 = "p3" }
};