tags:

views:

95

answers:

1

I have a child property of a child property in my entity. I have a Get method as such:

List<T> Find(Expression<Func<T, bool>> where, 
             params Expression<Func<T, object>>[] toInclude);

The way I normally load just the first child property is to do this:

myManager.Find(x => x.Id == id, x.ChildB);

However, I would like to be able to pull back the ChildC property which is a child of my ChildB property.

Is there anyway to perform this with the method signature I provided? I know normally I could do a .Include("ChildB.ChildC").

Edit: Added code per request

using(MyContext context = new MyContext())
{
    ObjectQuery<T> objectQuery = (ObjectQuery<T>)context.CreateObjectSet<T>();
    foreach(var include in toInclude)
    {
        objectQuery = objectQuery.Include(include);
    }

    return objectQuery.Where<T>(where);
}
A: 

If you are talking about LINQ-to-SQL, then you would configure the DataContext before executing any queries against it.

Something like:

var options = new DataLoadOptions();
options.LoadWith<ChildB>(b => b.ChildC);
dataContext.LoadOptions = options;
Jay
I am doing LINQ-to-Entities, however, I was hoping that the developer could pass a list of Navigation Properties they wanted to include without having to deal with the Context.
Brandon