Best practices when using a predicate

Posts   
 
    
Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 13-Apr-2005 20:07:12   

Hi All,

I have the following which works ok:

     Public Shared Function GroupStudentCountByGroupIdent(ByVal groupIdent As Integer) As Integer
        Dim i As Integer

        Dim Filter As IPredicate = PredicateFactory.CompareValue(MedfordSchoolDistrict.Elementary.GradeBook.LLBL.GroupStudentFieldIndex.GroupIdent, ComparisonOperator.Equal, groupIdent)

        i = CType(_Adapter.GetScalar( _
 EntityFieldFactory.Create(Elementary.GradeBook.LLBL.GroupStudentFieldIndex.GroupIdent), Nothing, _
  AggregateFunction.CountRow, Filter, Nothing), Integer)

        Return i
    End Function

The GroupIdent is a FK into GroupStudent. Am I creating the Filter correctly or is there a better way using a relationship predicate.

Thanks,

Fishy

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 14-Apr-2005 10:01:20   

It looks ok, what I'd do if I were you is to add some Imports statements at the top of the file to lower the amount of text you have to type for the indexes for example simple_smile )

Frans Bouma | Lead developer LLBLGen Pro