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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:13:09+00:00 2026-05-16T06:13:09+00:00

Ever since I started using an ORM for my day to day data access.

  • 0

Ever since I started using an ORM for my day to day data access. I’ve started to think about how much I should rely formatting functions for my columns. By formatting functions, I mean such things as Oracle’s decode(), instr() and initcap().

Example

Say I’m selecting this column using formatting in Oracle.

(to_number(to_char(to_date('1', 'J') + (EndTime - StartTime), 'J') - 1) * 24)
 + (to_char(to_date('00', 'HH24') + (EndTime - EndTime), 'HH24')) 
 || ':' ||
 to_char(to_date('00', 'MI') + (EndTime - StartTime), 'MI')
 as duration_time

It’s not very pretty, I know. Since formatting something like that using an ORM (I’m using NHibernate) is probably a waste of time. I was thinking I could simply allow me DTO to take care of that formatting. I could use something like this in my C# set property.

public TimeSpan DurationTimeSpan
{
 get
 {
  return EndTime.Subtract(StartTime);
 }
}

So my question is, should I let me DTO object take care of such formatting? Or is a DTO object not supposed to be responsible for such thing? Personally, it looks like it might be far cleaner to let me DTO’s set properties to do such formatting. From the looks of it, most formatting can probably be achieved with very simple C#.

  • 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-16T06:13:10+00:00Added an answer on May 16, 2026 at 6:13 am

    This definitely sounds like something that should be done well away from the database. The purpose of the database is to store and provide data for your application. Formatting is something which is client-specific – and shouldn’t be part of the query, IMO.

    Aside from anything else, I suspect you’ll find it a lot easier to code/test/debug the formatting in .NET than in SQL 🙂

    Now that doesn’t mean putting the logic in your DTOs, necessarily. What if you have two different client views which need to present the same data in different ways? If your DTOs really are just meant to transport the data, they shouldn’t worry about how it’s presented to the user. That should be in your UI logic. By all means make the DTO convert from the database representation (e.g. “number of seconds”) into a more idiomatic .NET type (TimeSpan) but I’d leave formatting to the UI layer.

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

Sidebar

Ask A Question

Stats

  • Questions 519k
  • Answers 519k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It doesn't work because you don't call the other anonymous… May 16, 2026 at 8:22 pm
  • Editorial Team
    Editorial Team added an answer If you can't change the type of your input array… May 16, 2026 at 8:22 pm
  • Editorial Team
    Editorial Team added an answer Implementation: public static TValue GetOrAdd<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey… May 16, 2026 at 8:22 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Ever since I started using .NET, I've just been creating Helper classes or Partial
Ever since I started programming properly using good old VB6 and up until present
It's been around 5 months since I picked up a PHP book and started
I now develop websites and XML interfaces since 7 years, and never, ever came
I've pretty much tried every Python web framework that exists, and it took me
I've been programming with Java for Android quite some while now. Since performance is
There are a lot of questions out there about whether singletons are bad, and
I've been thinking about doing my own language (practicality: it's a thought experiment). One
Ok so I just read this question Do you ever use the volatile keyword
I'm working on an old web application my company uses to create surveys. I

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.