How to specify DateTime kind when using Projection
See original GitHub issueI 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:
- Created 6 years ago
- Comments:15 (7 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ll try again 😃 Make a gist that we can execute and see fail. Like this.
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.