Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7739357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:30:08+00:00 2026-06-01T08:30:08+00:00

I need to implement a class called Foo where I need to Get and

  • 0

I need to implement a class called Foo where I need to Get and Save through a data access.

I can imagine I need to classes, one is to access, get and save data from an XmlFile, and another is the service which returns objects through like queries (GetFooById, GetFooByLevel, …), that’s my first though. That’s the reason why I want to clarify this design and what things I need to separate.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:30:09+00:00Added an answer on June 1, 2026 at 8:30 am

    I think you’re on the right track with the repository pattern.
    You can do something like this

    public interface IFooRepository
    {
       void Save(Foo);
       Foo GetById(int id);
       Foo GetByLevel(int level) 
    }
    
     public class FooXmlRepository:IFooRepository
      {
           //implementation
       }
    
      IFooRepository repo= new FooXmlRepository(); //or via your favorite DI container
    

    In this way the Foo object is decoupled by the storage concerns. And later if you want to use a db instead of xml, just write another implementation. The app will be using the interface so you don’t have to change anything else that the assignment of ‘repo’.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

class Foo(){ public List<string> SomeCollection; } I need to implement an event which can
I need to implement simple function that is called from multiple threads. The logic
I need to implement in my class Invoke() method with the same behavior as
I need to implement own TreeView with blinked TreeNode. My prototype is: public class
I have a parent and child class that both need to implement IDisposable .
I got these virtual classes from a library that implement an algorithm in the
I'd like to create a class called Object to be able to implement toString(),
I have a class called XorIsoStoreFileStream inheriting from IsolatedStorageFileStream, and the point is that
Quirky question: Imagine that I have a base class called BaseFoo. I have an
I have a base-class called Element. Some other classes (like Label and Image) both

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.