Hi,
This is an attempt to code your scenario.
class Program
{
static void Main(string[] args)
{
IEnumerable<Employee> empCollection = null;
var result = from e in empCollection
select new
{
EmployeeName = e.Name,
PrimaryContact = e.Contacts.Select(c => c.IsPrimaryContact).First()
};
}
}
public class Employee
{
public string Name { get; set; }
public IEnumerable<Contact> Contacts { get; set; }
}
public class Contact
{
public int ContactID { get; set; }
public string EmailId { get; set; }
public string Telephone { get; set; }
public bool IsPrimaryContact { get; set; }
}
Hope it helps :)