Refresh Collection

Posts   
 
    
Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 09-Sep-2005 19:29:18   

Hello Fellow classmates,

I have the following code to retrieve students with associated SubjectAreaTchrStud and GroupStudent collections:

    Public Shared Function GetStudentsByStudentIds(ByVal studentIds() As String) As EntityCollection
        GetStudentsByStudentIds = New EntityCollection(New StudentEntityFactory)

        Dim Filter As IRelationPredicateBucket = New RelationPredicateBucket
        Filter.PredicateExpression.Add(PredicateFactory.CompareRange( MedfordSchoolDistrict.Elementary.GradeBook.LLBL.StudentFieldIndex.StudentId, studentIds))

        Dim PrefetchPath As IPrefetchPath2 = New PrefetchPath2(CType(EntityType.StudentEntity, Integer))
        PrefetchPath.Add(StudentEntity.PrefetchPathSubjectAreaTchrStud)
        PrefetchPath.Add(StudentEntity.PrefetchPathGroupStudent)

        _Adapter.FetchEntityCollection(GetStudentsByStudentIds, Filter, Nothing, Nothing, PrefetchPath)

        Return GetStudentsByStudentIds
    End Function

It works fine.

Now, the GroupStudent records change in the database.

I want to be able to refetch just the GroupStudent data for every student in my Student collection.

How would I go about doing this?

Thanks,

Fishy

Paul.Lewis
User
Posts: 147
Joined: 22-Aug-2005
# Posted on: 10-Sep-2005 04:50:59   

Fishy wrote:

Now, the GroupStudent records change in the database.

What mechanism are you using to determine records have been modified? Are you in a connected or disconnected environment?

Fishy wrote:

I want to be able to refetch just the GroupStudent data for every student in my Student collection.

The simplest way would be to refetch the entire collection. This would ensure all data is current; to a point in time. Fetching individual related entities would probably take more time then grabbing it all.

Fishy wrote:

How would I go about doing this?

Recall the function you described above.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 10-Sep-2005 12:58:28   

You could also use a Context and simply refetch the graph with prefetch paths. You'll keep your original objects and get new ones/updated ones for the ones which have changed.

Frans Bouma | Lead developer LLBLGen Pro
Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 12-Sep-2005 17:50:28   

Otis wrote:

You could also use a Context and simply refetch the graph with prefetch paths. You'll keep your original objects and get new ones/updated ones for the ones which have changed.

Ok, I found it in your Generated code - Using the context, Adapter section. Your product is so deep it's sometimes difficult to understand all that you can do with it.

btw, your doc has an error. Search and replace 'for for' with 'for'. simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 15-Sep-2005 14:52:59   

Fishy wrote:

Otis wrote:

You could also use a Context and simply refetch the graph with prefetch paths. You'll keep your original objects and get new ones/updated ones for the ones which have changed.

Ok, I found it in your Generated code - Using the context, Adapter section. Your product is so deep it's sometimes difficult to understand all that you can do with it.

simple_smile You know, it is so big now I don't even know what it can do anymore, I mean: every detail. hehe simple_smile

btw, your doc has an error. Search and replace 'for for' with 'for'. simple_smile

thanks simple_smile Though if I want to say 'For example' after a 'for', I have to specify 'for' twice or not?-> "This is required for for example refetching trees of objects". (I found the other one)

Frans Bouma | Lead developer LLBLGen Pro