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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:40:40+00:00 2026-05-23T04:40:40+00:00

Say I have a POCO that stores a date range as follows: public class

  • 0

Say I have a POCO that stores a date range as follows:

public class DateRange()
{
public DateTime FromDate{get;set;}
public DateTime ToDate{get;set;}
}

I want to be able to save a half day at the beginning and/or end of the range. To do this I’m going to present my data as a jqueryui date picker for a from date and to date as well as a checkbox next to each datepicker to represent a 1/2 day. My viewmodel would look something like this:

public class DateRangeModel()
{
public DateTime FromDate {get; set;}
public DateTime ToDate{get;set;}
public bool IsFromDateHalfDay{get; set;}
public bool IsToDateHalfDay {get; set;}
}

When the 1/2 day checkbox is checked for the FromDate I need to save the FromDate in the entity as the selected day + 12 hours and when the 1/2 day checkbox is selected for the ToDate in the ViewModel I need to save the ToDate in the entity as the selected day + 12 hours.

Is it possible to do this using Automapper? If not could you suggest a better/different approach? I dont want to have the bools representing the half-days in the entity because I want to use the DateTimes alone for calculations.

Some Examples (Still contemplating how i should represent a range of 1 day and 1/2 a day – going to need to test calculating ranges a lot!):

A Date Range of 1/2 Day From 24th May to a full day 27th May:
2011-05-24 12:00:00.000 => 2011-05-28 00:00:00.000

A Date Range of Full Day From 24th May to a 1/2 day 27th May:
2011-05-24 00:00:00.000 => 2011-05-27 12:00:00.000

A Half Day on 24th May:
2011-05-24 12:00:00.000 => 2011-05-25 00:00:00.000     

A Full Day on 24th May:
2011-05-24 12:00:00.000 > 2011-05-25 00:00:00.000
  • 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-23T04:40:41+00:00Added an answer on May 23, 2026 at 4:40 am

    Are we to assume the FromDate/ToDate can only be Full Days (12:00 AM) or Half Days (12:00 PM)?

    Domain to View (if needed):

    CreateMap<DateRange, DateRangeModel>()
        .ForMember(dest => dest.IsFromDateHalfDay, opts => opts.MapFrom(src=>src.FromDate.Hour == 12))
        .ForMember(dest => dest.IsToDateHalfDay, opts => opts.MapFrom(src=>src.ToDate.Hour == 12));
    

    View to Domain

    CreateMap<DateRangeModel, DateRange>()
        .ForMember(dest => dest.FromDate, opts => opts.MapFrom(src=>src.FromDate.AddHours(-1 * src.IsFromDateHalfDay ? 12 : 0))
        .ForMember(dest => dest.ToDate, opts => opts.MapFrom(src=>src.ToDate.AddHours(src.IsToDateHalfDay ? 12 : 0));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a class named Frog, it looks like: public class Frog {
I have a setup with Client -> WCF -> POCO -> EF4. Say I
Let's say I have an Entity in my Entity Framework Model that is named
Say I have a class called Money which has parameters Dollars and Cents I
Say we have the following simple data-frame of date-value pairs, where some dates are
Let's say have something like: SELECT energy_produced, energy_consumed, timestamp1 AS timestamp FROM ( SELECT
Say we have the following method: private MyObject foo = new MyObject(); // and
Say I have the following file structure: app/ app.py controllers/ __init__.py project.py plugin.py If
Say you have an application divided into 3-tiers: GUI, business logic, and data access.
Say I have an ASMX web service, MyService. The service has a method, MyMethod.

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.