Edit: My question isn't about a using block and how it works. My question is about the difference in the two ways to do it, shown below.
I'm reading the CQRS Journey Guide, and I don't understand this line of code:
using (repo as IDisposable)
What does that mean? Why use it as IDisposable? In a typical using block, one doesn't need to use it as IDisposable:
using (var repo = this.respositoryFactory()) { // ... }
Any idea why the authors wrote it the first way instead of the second way?
This is the method in which that code appears:
private Conference.Web.Public.Models.Conference GetConference(string conferenceCode)
{
var repo = this.repositoryFactory();
using (repo as IDisposable)
{
var conference = repo.Query<Conference>()
.First(c => c.Code == conferenceCode);
var conferenceModel =
new Conference.Web.Public.Models.Conference
{
Code = conference.Code,
Name = conference.Name,
Description = conference.Description
};
return conferenceModel;
}
}