Return first row

Posts   
 
    
ry4n
User
Posts: 5
Joined: 20-Sep-2011
# Posted on: 14-Nov-2011 11:37:19   

Hi im really new to llblgen and was wondering how to do this simple task.. sigh flushed

currently I'm grabbing this row by row field.id = 1, but rows can be moved and deleted and i will always want **the first **row so how do i grab the first row always in llblgen ?



           InternalSystemDefaultsEntity systemDefaultsEntity = new InternalSystemDefaultsEntity();

                //___________________________
                // create required filters
                RelationPredicateBucket predBkt = new RelationPredicateBucket();

                IPredicateExpression predExp = new PredicateExpression();

                //get collection then get first row  ** needs changed !!
                predExp.Add(InternalSystemDefaultsFields.InternalSystemDefaultId ==  1);
            
                // predExp.Add
                predBkt.PredicateExpression.Add(predExp);

                return systemDefaultsEntity;


Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 14-Nov-2011 14:16:36   

How would you do it in plain SQL?

pkothare
User
Posts: 1
Joined: 23-Sep-2011
# Posted on: 12-Dec-2011 00:21:42   

I am interested in getting a response to this too.

The SQL equivalent is:

SELECT TOP (1) * FROM [someTable]

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 12-Dec-2011 08:17:33   

When fetching the EntityCollection, pass 1 to the maxNumberOfItemsToReturn parameter.

public void FetchEntityCollection( IEntityCollection2 collectionToFill, IRelationPredicateBucket filterBucket, int maxNumberOfItemsToReturn )