using System.Collections.Generic;
public static void Main()
IList<SrvProdAppDtl> SrvProdAppDtl = new List<SrvProdAppDtl>() {
new SrvProdAppDtl() { ServerId = 1152, ProductId = 121, AppId = 5337} ,
new SrvProdAppDtl() { ServerId = 1153, ProductId = 122, AppId = 5338} ,
new SrvProdAppDtl() { ServerId = 1154, ProductId = 123, AppId = 5339}
IList<ServerDtl> ServerDtlList = new List<ServerDtl>() {
new ServerDtl(){ ServerId = 1152, ServerName="Server1"},
new ServerDtl(){ ServerId = 1153, ServerName="Server2"},
new ServerDtl(){ ServerId = 1154, ServerName="Server3"},
new ServerDtl(){ ServerId = 1155, ServerName="Server4"},
new ServerDtl(){ ServerId = 1156, ServerName="Server5"}
IList<ProductDtl> ProductDtlList = new List<ProductDtl>() {
new ProductDtl(){ ProductId = 121, ProductName="Product1"},
new ProductDtl(){ ProductId = 122, ProductName="Product2"},
new ProductDtl(){ ProductId = 123, ProductName="Product3"},
new ProductDtl(){ ProductId = 124, ProductName="Product4"},
new ProductDtl(){ ProductId = 125, ProductName="Product5"}
IList<AppDtl> AppDtlList = new List<AppDtl>() {
new AppDtl(){ AppId = 5337, AppName="App1"},
new AppDtl(){ AppId = 5338, AppName="App2"},
new AppDtl(){ AppId = 5339, AppName="App3"},
new AppDtl(){ AppId = 5333, AppName="App4"},
var result = (from spdtl in SrvProdAppDtl
join srv in ServerDtlList
on spdtl.ServerId equals srv.ServerId
into temp1 from t1 in temp1.DefaultIfEmpty()
join prod in ProductDtlList
on spdtl.ProductId equals prod.ProductId
into temp2 from t2 in temp2.DefaultIfEmpty()
on spdtl.AppId equals app.AppId
into temp3 from t3 in temp3.DefaultIfEmpty()
ServerName = t1.ServerName,
ProductName=t2.ProductName,
foreach (var obj in result)
Console.WriteLine("{0} {1} {2}", obj.ServerName,obj.ProductName,obj.AppName);
public class SrvProdAppDtl{
public int ServerId { get; set; }
public int ProductId { get; set; }
public int AppId { get; set; }
public int ServerId { get; set; }
public string ServerName { get; set; }
public int ProductId { get; set; }
public string ProductName { get; set; }
public int AppId { get; set; }
public string AppName { get; set; }