Ok, I think I have it figured out. I was not using the same LinqMetaData instance. There was no way for you to know this without a complete zip of the solution.
The good news is I have refactored out any duplicate code. This code works great now.
/// <summary>
/// Gets a queryable list of contacts
/// </summary>
/// <returns>queryable list of contacts</returns>
public override IQueryable<Contact> GetQueryable()
{
var qry = _transaction.CreateLinqProvider().Contact.Select(ContactEntityMap());
return qry.AsQueryable();
}
/// <summary>
/// ContactEntity to Contact map.
/// </summary>
/// <returns>a function that performs mapping between LLBL and the Modal</returns>
public Func<ContactEntity, Contact> ContactEntityMap()
{
return (c => new Contact
{
ID = c.Identifier,
Created = c.Created,
Modified = c.Modified,
ObjectType = (EntityType) c.TypeId,
FirstName = c.FirstName,
LastName = c.LastName,
MiddleName = c.MiddleName,
Salutation = c.Salutation,
Suffix = c.Suffix,
Title = c.Title,
Addresses = new LazyList<Address>(() => _addressRepository.GetQueryableByGuid(c.Identifier).ToList())
});
}
This will load my modal from my LLBLGen entities. Also, the address colllection is loaded only when used.
Bryan