6 Tips of Separation: Listing 3.

ViewModel code to call LoadById on a repository.

private void Load()
{
  m_Repository.LoadById(
    new ReturnResult<IPerson>(LoadCompleted), 
    IdToLoad.Value);
}

private void LoadCompleted(ReturnResult<IPerson> callback)
{
  if (callback.Error != null)
  {
    ShowMessage(callback.Error);
  }
  else
  {
    var adapter = new PersonModelToViewModelAdapter();
    adapter.Adapt(callback.Result, this);
    m_Model = callback.Result;
  }
}

About the Author

Benjamin Day is a consultant, trainer, and author specializing in software development, project management, and leadership. Ben’s main areas of emphasis include Azure DevOps, C#, Angular, Scrum, software testing, and software architecture. He is a Microsoft MVP, a certified Scrum trainer via Scrum.org, and speaks regularly at VSLive. His online courses are available at YouTube and at http://www.pluralsight.com. Ben is also the founder of https://SlideSpeaker.ai. He can be contacted via http://www.benday.com.

comments powered by Disqus

Featured

  • Spring AI 2.0 Goes GA, Giving Java Developers a More Mature AI App Stack

    Spring AI 2.0 advances the Java framework for generative AI apps with a Spring Boot 4 baseline, cleaner agentic tooling, Model Context Protocol support and vendor-backed integrations including Azure Cosmos DB.

  • Kubernetes for Developers

    Microsoft's Dan Wahlin previews his introductory "Kubernetes for Developers" session at Visual Studio Live! San Diego 2026, explaining how developers can get past the Kubernetes learning curve by starting locally, mastering Pods first, and using Services to make containerized applications reliably accessible.

  • VS Code Keeps Eye on Costs in v1.126 Update

    Visual Studio Code 1.126 adds session-level Copilot cost information, continuing Microsoft's recent focus on helping developers monitor and manage usage-based GitHub Copilot billing.

  • Open VSX 1.0.0 Puts Focus on Open Extension Registry for VS Code Ecosystem

    Eclipse Open VSX has reached 1.0.0, highlighting its role as a vendor-neutral registry for VS Code-compatible extensions.

Subscribe on YouTube