Documentupload
==============
using System.Collections.Generic;
public class DocumentUpload
{
public int ID { get; set; }
public string DocName { get; set; }
public int PortalActivityId { get; set; }
public static List<DocumentUpload> GetAllFiles()
{
return new List<DocumentUpload>()
{
new DocumentUpload { ID = 1, DocName = "Mark", PortalActivityId = 1 },
new DocumentUpload { ID = 2, DocName = "Steve", PortalActivityId = 2 },
new DocumentUpload { ID = 3, DocName = "Ben", PortalActivityId = 1 },
new DocumentUpload { ID = 4, DocName = "Philip", PortalActivityId = 1 },
new DocumentUpload { ID = 5, DocName = "Mary", PortalActivityId = 2 },
new DocumentUpload { ID = 6, DocName = "Valarie", PortalActivityId = 2 },
new DocumentUpload { ID = 7, DocName = "John", PortalActivityId = 1 },
new DocumentUpload { ID = 8, DocName = "Pam", PortalActivityId = 1 },
new DocumentUpload { ID = 9, DocName = "Stacey", PortalActivityId = 2 },
new DocumentUpload { ID = 10, DocName = "Andy", PortalActivityId = 1}
};
}
}
PortalUpload
==============
using System.Collections.Generic;
public class PortalActivity
{
public int ID { get; set; }
public string ClientName { get; set; }
public static List<PortalActivity> GetAllPortalDetails()
{
return new List<PortalActivity>()
{
new PortalActivity { ID = 1, ClientName = "IT"},
new PortalActivity { ID = 2, ClientName = "HR"},
new PortalActivity { ID = 3, ClientName = "Payroll"},
};
}
}
Program.Cs
============
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LinqGroup
{
class Program
{
static void Main(string[] args)
{
var filesByPortalId = PortalActivity.GetAllPortalDetails().GroupJoin(DocumentUpload.GetAllFiles(),
d => d.ID,
e => e.PortalActivityId,
(portalActivity, documentUpload) => new
{
PortalActivity = portalActivity,
DocumentUpload = documentUpload
});
foreach (var portalIdDetails in filesByPortalId)
{
Console.WriteLine("\nThe PoratalActivity Id: "+portalIdDetails.PortalActivity.ID + "The PortalClientName: " + portalIdDetails.PortalActivity.ClientName);
foreach (var documnetFile in portalIdDetails.DocumentUpload)
{
Console.WriteLine("The Documemtn Id: " + documnetFile.ID + "- The Portal Id: " + documnetFile.PortalActivityId + " The File Name: " + documnetFile.DocName + " portalClientName :" + portalIdDetails.PortalActivity.ClientName);
}
Console.WriteLine();
}
Console.ReadLine();
}
}
}
==============
using System.Collections.Generic;
public class DocumentUpload
{
public int ID { get; set; }
public string DocName { get; set; }
public int PortalActivityId { get; set; }
public static List<DocumentUpload> GetAllFiles()
{
return new List<DocumentUpload>()
{
new DocumentUpload { ID = 1, DocName = "Mark", PortalActivityId = 1 },
new DocumentUpload { ID = 2, DocName = "Steve", PortalActivityId = 2 },
new DocumentUpload { ID = 3, DocName = "Ben", PortalActivityId = 1 },
new DocumentUpload { ID = 4, DocName = "Philip", PortalActivityId = 1 },
new DocumentUpload { ID = 5, DocName = "Mary", PortalActivityId = 2 },
new DocumentUpload { ID = 6, DocName = "Valarie", PortalActivityId = 2 },
new DocumentUpload { ID = 7, DocName = "John", PortalActivityId = 1 },
new DocumentUpload { ID = 8, DocName = "Pam", PortalActivityId = 1 },
new DocumentUpload { ID = 9, DocName = "Stacey", PortalActivityId = 2 },
new DocumentUpload { ID = 10, DocName = "Andy", PortalActivityId = 1}
};
}
}
PortalUpload
==============
using System.Collections.Generic;
public class PortalActivity
{
public int ID { get; set; }
public string ClientName { get; set; }
public static List<PortalActivity> GetAllPortalDetails()
{
return new List<PortalActivity>()
{
new PortalActivity { ID = 1, ClientName = "IT"},
new PortalActivity { ID = 2, ClientName = "HR"},
new PortalActivity { ID = 3, ClientName = "Payroll"},
};
}
}
Program.Cs
============
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LinqGroup
{
class Program
{
static void Main(string[] args)
{
var filesByPortalId = PortalActivity.GetAllPortalDetails().GroupJoin(DocumentUpload.GetAllFiles(),
d => d.ID,
e => e.PortalActivityId,
(portalActivity, documentUpload) => new
{
PortalActivity = portalActivity,
DocumentUpload = documentUpload
});
foreach (var portalIdDetails in filesByPortalId)
{
Console.WriteLine("\nThe PoratalActivity Id: "+portalIdDetails.PortalActivity.ID + "The PortalClientName: " + portalIdDetails.PortalActivity.ClientName);
foreach (var documnetFile in portalIdDetails.DocumentUpload)
{
Console.WriteLine("The Documemtn Id: " + documnetFile.ID + "- The Portal Id: " + documnetFile.PortalActivityId + " The File Name: " + documnetFile.DocName + " portalClientName :" + portalIdDetails.PortalActivity.ClientName);
}
Console.WriteLine();
}
Console.ReadLine();
}
}
}
No comments:
Post a Comment