New Posts New Posts RSS Feed: Repositories in UOW do not work
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Repositories in UOW do not work

 Post Reply Post Reply
Author
-ook View Drop Down
Groupie
Groupie
Avatar

Joined: 26-Aug-2007
Location: Australia
Posts: 41
Post Options Post Options   Quote -ook Quote  Post ReplyReply Direct Link To This Post Topic: Repositories in UOW do not work
    Posted: 30-Jul-2013 at 11:31pm
I have configured a Unit of Work (UOW) class that contains a variety of GlobalCacheRepositories pretty much exactly as per the TempHire reference application.
 
I have a GlobalChache class that has been loaded with the data these repositories reference as well (again as per TempHire).
 
However when I try to obtain data (in the ViewModel) from the UOW repositories 0 records are always returned. As a test I have passed the Global Cache to the function and queries that directly, and records are returned.
 
e.g.
 
                 // this will return 0 records
                var issuetreatments = await UnitOfWork.IssueTreatments.AllAsync(q => q.OrderBy(s => s.Name));
 
                // this will return 5 records (the correct amount)
                var issuetreatments2 = cache.Get<IssueTreatement>();
 
Does anyone have any pointers as to why this would be occuring?
 
Thanks
Mark
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 30-Jul-2013 at 11:52pm
Most likely the EntityManagerProvider.ManagerCreated event gets triggered before the repositories had a chance to install their even handler. Make sure you don't access the Manager property before all the repositories get instantiated. 
Back to Top
-ook View Drop Down
Groupie
Groupie
Avatar

Joined: 26-Aug-2007
Location: Australia
Posts: 41
Post Options Post Options   Quote -ook Quote  Post ReplyReply Direct Link To This Post Posted: 31-Jul-2013 at 2:29pm
Thankyou, yes that was indeed the issue.
 
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down