That's fantastic thank you! I can't believe how close I was and just couldn't get it.
I was able to get in bucket predicates, so out of curiosity is there a similar way to get in prefetch paths?
Wherever I need to define my filter
Dictionary<EntityField2, string> filterItems = new Dictionary<EntityField2, string>();
filterItems.Add(ContactFields.TypeCode, DropDownList.SelectedValue);
Then in the method for getting the collection
public static IEntityCollection2 GetEntityCollection<T>(Dictionary<EntityField2, string> filterItems = null) where T : EntityBase2
{
using (DataAccessAdapter adapter = new DataAccessAdapter(CONNECTION_PMNDataCenter))
{
IEntityCollection2 collection = new EntityCollection<T>();
RelationPredicateBucket bucket = new RelationPredicateBucket();
try
{
if (filterItems != null && filterItems.Count > 0)
{
foreach (KeyValuePair<EntityField2, string> entry in filterItems)
{
bucket.PredicateExpression.Add(entry.Key == entry.Value);
}
}
else
{
bucket = null;
}
//Something for Prefetch paths here??
adapter.FetchEntityCollection(collection, bucket);
}
catch
{
//Log Exception
}
return collection;
}
}
I was looking for a way to iterate possible prefetch paths that may be on an Entity, but I was unsuccessful. And there's the real problem of having the prefetch grab everything related to an entity which could end up being millions of unnecessary items.
So what do you think?