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

  • Home
  • SEARCH
  • 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 9178299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:31:08+00:00 2026-06-17T17:31:08+00:00

Roughly following some designs I’ve seen, I’m building an ASP.NET application where each of

  • 0

Roughly following some designs I’ve seen, I’m building an ASP.NET application where each of my business objects has an associated Repository and Service. The repositories use nHibernate’s ISession to perform CRUD operations, and the corresponding service accesses the repository members.

When using an ObjectDataSource in ASP.NET, is it considered bad practice to bind it directly to a repository instead of to a service (thus entirely skipping the service layer)? Or is the service layer not really necessary when just performing simple CRUD operations?

// Repository interface
public partial interface IRepository<T>
{
    void Add(T entity);
    void Update(T entity);
    void Remove(T entity);
    ICollection<T> GetAll();
    T GetByKey(int _ID);
}

// Service example
public class TestService : IService<Test>
{
    private static TestRepository _repository;
    ...

    public virtual ICollection<Test> FindAll()
    {
        return (_repository.GetAll());
    }

    public virtual Test FindBy(int Id)
    {
        return (_repository.GetByKey(Id));
    }

    public virtual void Save(Test entity)
    {
        _repository.Update(entity);
    }

    public virtual void Add(Test entity)
    {
        _repository.Add(entity);
    }

    public virtual void Remove(Test entity)
    {
        _repository.Remove(entity);
    }
}
  • 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-17T17:31:10+00:00Added an answer on June 17, 2026 at 5:31 pm

    Definitely your UI shouldn’t know about the data access. Even though you are not manipulating the data coming from the database, it is a good practice to have at least one more layer(Service, or Business Layer) and let your UI interact with the service. If I were you, I would do a poorman MVC for the Asp.net so that I can unit test

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

Sidebar

Related Questions

I have some data in a table that looks roughly like the following: table
Most of the applications I've seen that use TCP, do roughly the following to
I have some code that very roughly resembled the following: class C { string
I have some strings that are roughly 10K characters each. There is plenty of
I have some files that contain logs of objects. Each file can store objects
The project has roughly the following structure: include/ lib_name/ public_foo.h public_bar.h src/ CMakeLists.txt foo.c
I have some IronPython code in a C# class that has the following two
I have some tables roughly like so: Client: id name Employee id name Email
I have elements structured roughly like this: http://jsfiddle.net/zyySd/ Is there any way to achieve
I have roughly 12 computers that each have the same script on them. This

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.