question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to specify DateTime kind when using Projection

See original GitHub issue

I want all my DateTime fields to be Utc. I have tried numerous options but none seem to work. Can someone please help me. The clocks have just gone forward in the UK and now everything is broken 😃

So far I’ve tried this:

cfg.CreateMap<DateTime, DateTime>().ProjectUsing(i => new DateTime(i.Year, i.Month, i.Day, i.Hour, i.Minute, i.Second, DateTimeKind.Utc));
cfg.CreateMap<DateTime?, DateTime?>().ProjectUsing(i => new DateTime(i.Value.Year, i.Value.Month, i.Value.Day, i.Value.Hour, i.Value.Minute, i.Value.Second, DateTimeKind.Utc));

And this

cfg.CreateMap<DateTime, DateTime>().ConstructProjectionUsing(i => new DateTime(i.Year, i.Month, i.Day, i.Hour, i.Minute, i.Second, DateTimeKind.Utc));
cfg.CreateMap<DateTime?, DateTime?>().ConstructProjectionUsing(i => new DateTime(i.Value.Year, i.Value.Month, i.Value.Day, i.Value.Hour, i.Value.Minute, i.Value.Second, DateTimeKind.Utc));

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
lbargaoanucommented, Mar 27, 2017

I’ll try again 😃 Make a gist that we can execute and see fail. Like this.

0reactions
lock[bot]commented, May 6, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to specify that DateTime objects retrieved from ...
Is there a way to tell Entity Framework (Code First) when creating DateTime objects in C# to always use DateTimeKind.UTC ?
Read more >
DateTime.SpecifyKind(DateTime, DateTimeKind) Method
The SpecifyKind method creates a new DateTime object using the specified kind parameter and the original time value. Important. The returned DateTime value...
Read more >
Entity-framework – DateTime.Kind set to unspecified, not ...
Assuming you are using EF6 and you want to set the Kind property of any DateTime value retrieved from the database to Utc...
Read more >
DateTime Projection
DateTime Projection Functions contains functions to extract the different parts from a DATE and to map DATEs to other data types and vice ......
Read more >
Supported types for partition projection
Use the enum type for partition columns whose values are members of an enumerated set (for example, airport codes or AWS Regions). Define...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found