Hi
I've created a base business class for my application which performs basic CRUD operations based on EF 4:
public abstract class BusinessBase<T> where T : ObjectContext, new()
{
public virtual List<TEntity> GetByPredicate<TEntity>(Expression<Func<TEntity, bool>> predicate) where TEntity : EntityObject
{
using (T objectContext = new T())
{
ObjectSet<TEntity> objectSet = objectContext.CreateObjectSet<TEntity>();
objectSet.MergeOption = MergeOption.NoTracking;
return objectSet.Where(predicate).ToList();
}
}
GetPredicate methods works well to retrieve all entity objects of type TEntity. But I need to be able to fetch the related records as well. I also need to set the MergeOption property of all related entities to "NoTracking" for some reasons.
Is there a general way to find and iterate through the Navigation Properties of an entity in EF 4?
Thanks