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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:44:58+00:00 2026-06-13T21:44:58+00:00

What is the best practice for executing a generic, table-less SQL query within an

  • 0

What is the best practice for executing a generic, table-less SQL query within an MVC architecture?

I’m trying to use commands such as these:

SELECT getdate();
SELECT user;

Update:
This is actually for part of another project that co-exists alongside the MVC project. All of my tables so far are mapped using edmx from an existing database.

I’d like to use the date from the database in some internal calculations, rather than using the date from the server where the application/site are installed. My formulas go down to the milliseconds, and the time difference between the two servers involved throws off the math.

  • 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-13T21:45:00+00:00Added an answer on June 13, 2026 at 9:45 pm

    Implement them via Dapper:

    using(SqlConnection connection = new SqlConnection("myConnectionString"))
    {
        DateTime getDate = connection.Query<DateTime>("select getdate()").Single();
    }
    

    Query is an extension method that accepts a Type to map to and Single() gives you a scalar value.

    Dapper is the lightweight Orm by the guys on StackOverflow: http://code.google.com/p/dapper-dot-net/

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

Sidebar

Related Questions

What is considered best practice for executing recurring SQL queries? My understanding is to
Is there best practice about display errors in during controller action executing on view?
Best practice is to use unique ivs, but what is unique? Is it unique
The best practice seems to be to use assert for a condition that should
I'm looking for the best practice for executing encodeURIComponent (or some other function) for
What's the best practice for storing a large amount of image data in SQL
What is the best practice when serving files from the Zend Framework MVC? These
I am new to Prism and I am trying to determine a best practice
Short best practice question: If an object A is injected into another object B,
The 'best practice' (as I see it) to atomically create a new file, is

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.