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 3451896
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:11:42+00:00 2026-05-18T09:11:42+00:00

I am used to making separate Business Object and List<> classes for my DB

  • 0

I am used to making separate Business Object and List<> classes for my DB tables. Sometimes I just have a basic task in hand as displaying a list of year for a search box or having some values in a drop down.

Right now I am ending up with a lot of separate classes and List classes<> for these basic operations.

How can I make a single class for some basic tasks as these by using generics?
I want to have single class for some methods like get current year, employee names, Department Name/Code, Title etc. Please give me an example. I am using .NET 2.0.


Edit
After some searching, I found that I can achieve similar tasks by creating a DTO namespace.

What I don’t get right now is how to create multiple classes inside my DTO class. Say 1 class for just returning ‘year’, One for ‘Employee Name/Code’ and so on inside the single DTO class.

  • 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-05-18T09:11:42+00:00Added an answer on May 18, 2026 at 9:11 am

    You can map your classes with DB Table manually or you can use NHibernate which is an advanced ORM which works quiet well with .Net 2.0.

    Basically you can map your plain c# classes to DB table using a simple xml mapping file.

    Example a class called Product can

    public class Product
        {
            public Guid Id { get; set; }
            public string Name { get; set; }
            public string Category { get; set; }
            public bool Discontinued { get; set; }
        }
    

    can be mapped to a DB table using following mapping file.

    <?xml version="1.0" encoding="utf-8" ?>
    <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" 
                       assembly="FirstSolution" 
                       namespace="FirstSolution.Domain">
    
      <class name="Product">
        <id name="Id">
          <generator class="guid" />
        </id>
        <property name="Name" />
        <property name="Category" />
        <property name="Discontinued" />
      </class>
    
    </hibernate-mapping>
    

    This also has good support for .Net Collections. There is sure some learning curve but the productivity benefit is worth.

    More example can be found here.

    http://nhforge.org/wikis/howtonh/your-first-nhibernate-based-application.aspx

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

Sidebar

Related Questions

I've used all three of these when making local programmatic connections to databases. Is
So I was making a class the other day and used Eclipse's method to
Im looking for an algorithm to be used in a racing game Im making.
I used the LINQ to SQL designer in Visual Studio to create an object
We used the undocumented xp_fileexist stored procedure for years in SQL Server 2000 and
Never used a cache like this before. The problem is that I want to
I used to work in a place where a common practice was to use
I used jQuery to set hover callbacks for elements on my page. I'm now
When used like this: import static com.showboy.Myclass; public class Anotherclass{} what's the difference between
We used to use SourceSafe, and one thing I liked about it was that

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.