Hi All,
I'm novice to LLBL. I'm facing one problem while getting first row from multiple rows of same record using LLBL. Following is the code.
DataAccessAdapter adapter = new DataAccessAdapter();
ResultsetFields fields = new ResultsetFields(7);
fields.DefineField(AlbumFields.AlbumId, 0);
fields.DefineField(AlbumFields.Name, 1);
fields.DefineField(AlbumFields.Comment, 2);
fields.DefineField(AlbumFields.CoverArtImageId, 3);
fields.DefineField(ArtistFields.Name, 4, "ArtistName");
fields.DefineField(PublisherFields.Name, 5, "Publisher");
fields.DefineField(AlbumFields.AlbumId, 6, "Total", AggregateFunction.Count);
IRelationPredicateBucket bucket = new RelationPredicateBucket();
bucket.Relations.ObeyWeakRelations = true;
bucket.Relations.Add(AlbumEntity.Relations.AuditAlbumEntityUsingAlbumId, JoinHint.Inner);
bucket.Relations.Add(AlbumEntity.Relations.PublisherEntityUsingPublisherId, JoinHint.Left);
bucket.Relations.Add(AlbumEntity.Relations.ArtistAlbumEntityUsingAlbumId, JoinHint.Left);
bucket.Relations.Add(ArtistAlbumEntity.Relations.ArtistEntityUsingArtistId);
bucket.PredicateExpression.Add(AlbumFields.IsApproved == true);
bucket.PredicateExpression.AddWithAnd(AlbumFields.IsActive == true);
bucket.PredicateExpression.AddWithAnd(AlbumFields.AlbumId != albumId);
bucket.PredicateExpression.AddWithAnd(AlbumFields.MediaCategoryId == categoryId);
bucket.PredicateExpression.AddWithAnd(AuditAlbumFields.EventOccurred == ToxicBeatsValues.AuditEventOccured.VIEWED);
IGroupByCollection groupByClause = new GroupByCollection();
groupByClause.Add(fields[0]);
groupByClause.Add(fields[1]);
groupByClause.Add(fields[2]);
groupByClause.Add(fields[3]);
groupByClause.Add(fields[4]);
groupByClause.Add(fields[5]);
groupByClause.HavingClause = new PredicateExpression(fields[4].SetExpression(ArtistFields.Name).SetAggregateFunction(AggregateFunction.Count) == 1);
ISortClause sortClause = new SortClause(fields[6], null, SortOperator.Descending);
ISortExpression sortExpression = new SortExpression(sortClause);
DataTable dynamicList = new DataTable();
adapter.FetchTypedList(fields, dynamicList, bucket, NumberOfTopItems, sortExpression, false, groupByClause);
Above code returns muliple artists with same album id. Let's say it's returning 3 rows with different artistnames for same album id. Now I want to pickup first artist from these 3 rows. Can you please help me how to achieve that using LLBL? Thanks in advance.