I am having problems getting my prefetch to return anything... I am probably doing something wrong as I am fairly new to prefetches!! The example below is something I will make alot of use of so any help is much appreciated
I have 4 related tables
Product
ProductID
ProductName
ProductGroupMemberProductMap
ProductGroupMemberProductMapID
ProductID
Product GroupMemberID
ProductGroupMember
ProductGroupMemberID
ProductGroupMemberName
ProductGroupID
ProductGroup
ProductGroupID
Product GroupName
Therefore a ProductGroup (e.g. "Category") has a number of ProductGroupMembers (e.g. "Software" or "Hardware") and each product is associated with a member for each product group via the m:n table (I.e. Product A's category is software etc)
I am trying to return a collection of all products together with their respective ProductGroupMemberName for a specified ProductGroupID and am using the following code (that makes use of the 3rd party manager classes )
PrefetchPath2 myPrefetch = new PrefetchPath2( (int) EntityType.ProductEntity );
myPrefetch.Add(ProductEntity.PrefetchPathProductGroupMember);
IRelationPredicateBucket myBucket = new RelationPredicateBucket();
myBucket.Relations.Add(ProductEntity.Relations.ProductGroupMemberProductMapEntityUsingProductID);
myBucket.Relations.Add(ProductGroupMemberProductMapEntity.Relations.ProductGroupMemberEntityUsingProductGroupMemberID);
IPredicateExpression myExpression = new PredicateExpression();
myExpression.Add(PredicateFactory.CompareValue(ProductGroupMemberFieldIndex.ProductGroupID, ComparisonOperator.Equal, GroupID));
myBucket.PredicateExpression.Add(myExpression);
return FetchCollectionWithPrefetch((RelationPredicateBucket) myBucket,null,myPrefetch,myAdapter);
Where GroupID is the ProductGroupID that I want to analyse...
Firstly why did I have to add the relations to myBucket to get the fetch to work (they are the same relations that are in the prefetch)... is it because I need the relations for my predicate expression?
Secondly, I want to use the value of the ProductGroupMemberName in a Janus grid so I have added the following code to the ProductEntity usercoderegion
public string ProductGroupMember_Name
{
get
{
if (_productGroupMember.Items.Count != 1)
{
return String.Empty;
}
else
{
ProductGroupMemberEntity myEntity = (ProductGroupMemberEntity) _productGroupMember.Items[0];
return myEntity.Name;
}
}
and have set the DisplyMember for the grid column to ProductGroupMember_Name.
However nothing is displayed
Any help would be much appreciated