Using 4.1 selfserving.
Probably I’m searching with the wrong terms. Because I think the questions is easy but I cannot find it in the documentation.
I have a many to many relation between Product and Description. (See attachment)
table Product
Id
table Description
Id
table ProductDescription
ProductId
DescriptionId
Now I want all the descriptions for a product in a DataGridView (dgvTest) on a Product page.
The code I use (not working!!! ) seems rather complex. I think there must be an easy way. Someone has some hint(s) or a solution for me?
private void btnTest_Click(object sender, EventArgs e) {
dgvTest.DataSource = null;
ProductDescriptionCollection productDescriptionCollection = _product.GetMultiProductDescriptions(true);
FieldCompareValuePredicate productfilter = (FieldCompareValuePredicate)(ProductFields.Id == _product.Id);
DescriptionCollection descriptionCollection = new DescriptionCollection();
ISortExpression descriptionSorter = new SortExpression(DescriptionFields.Rank | SortOperator.Ascending);
//From Sample....
RelationCollection relationsToWalk = new RelationCollection();
relationsToWalk.Add(DescriptionEntity.Relations.ProductDescriptionEntityUsingDescriptionId);
relationsToWalk.Add(ProductDescriptionEntity.Relations.DescriptionEntityUsingDescriptionId);
relationsToWalk.Add(ProductEntity.Relations.ProductDescriptionEntityUsingProductId);
descriptionCollection.GetMulti(_productFilter, 0, descriptionSorter, _relationsToWalk);
dgvTest.DataSource = descriptionCollection;
}
Attachments
Filename |
File size |
Added on |
Approval |
Relation.GIF
|
28,951 |
28-Jan-2014 10:38.11 |
Approved |