You can add a params array that references each linked entity you want to eager load to the method signature in your data layer:
public static CustomerModel GetCustomer(int CustomerId, params string[] eagerLoadCollections)
{
var retVal = (from c in context.tblCustomers
where c.CustomerId == CustomerId
select new CustomerModel
{
CustomerId = c.CustomerId,
CustomerName = c.CustomerName
});
foreach(string eagerLoadCollection in eagerLoadCollections)
{
retVal = retVal.Include(eagerLoadCollection);
}
return retVal.FirstOrDefault();
}
This enables you to load as many related entity collections as you want:
var customer = DataLayer.GetCustomer(123);
or:
var customer = DataLayer.GetCustomer(123, "InvoiceHeaders", "OtherRelatedEntities", "etc.");
Whether it's the right way I can't say. It works for me :)