New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support temporal types with EF #279

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
3 participants
@lewischeng-ms
Contributor

lewischeng-ms commented Jan 19, 2016

Now in RESTier, supported mapping options for temporal types are:

EF Type SQL Type Edm Type Need ColumnAttribute?
System.DateTime DateTime/DateTime2 Edm.DateTimeOffset Y
System.DateTimeOffset DateTimeOffset Edm.DateTimeOffset N
System.DateTime Date Edm.Date Y
System.TimeSpan Time Edm.TimeOfDay Y
System.TimeSpan Time Edm.Duration N

Reference: https://msdn.microsoft.com/en-us/library/bb386947(v=vs.110).aspx#DateMapping

*Unless all the three types are DateTimeOffset, the time zone would always be assumed +00.00 to ensure the consistency of type conversion.

The basic CRUD and query options are tested with the temporal types. However due to a bug in OData Web API, currently built-in functions (e.g., hour, minute, etc.) on Edm.TimeOfDay cannot work well yet. And due to another bug in ODL, the type annotations of the temporal types in full metadata payload MAY be incorrect.

*Will provide documentation for this feature later.

@lewischeng-ms

This comment has been minimized.

Show comment
Hide comment
@lewischeng-ms

lewischeng-ms Jan 19, 2016

Contributor

The issue of built-in functions on Edm.TimeOfDay in OData Web API has been fixed by OData/WebApi#614. Thanks @xuzhg !

Contributor

lewischeng-ms commented Jan 19, 2016

The issue of built-in functions on Edm.TimeOfDay in OData Web API has been fixed by OData/WebApi#614. Thanks @xuzhg !

@rayao

This comment has been minimized.

Show comment
Hide comment
@rayao

rayao Jan 19, 2016

Will this cover EF configuration API HasColumnType("date")?

Will this cover EF configuration API HasColumnType("date")?

This comment has been minimized.

Show comment
Hide comment
@lewischeng-ms

lewischeng-ms Jan 19, 2016

Owner

Actually I am not sure about this part of code. They were just inferred from debugging in VS. I see different approach in your pull request if it is the right way to do that. I will remove my code and use yours.

Owner

lewischeng-ms replied Jan 19, 2016

Actually I am not sure about this part of code. They were just inferred from debugging in VS. I see different approach in your pull request if it is the right way to do that. I will remove my code and use yours.

This comment has been minimized.

Show comment
Hide comment
@rayao

rayao Jan 19, 2016

I verified that both "[Column(TypeName=)]" and "ModelBuilder.Entity().HasColumnType()" could be covered by my approach, but "ClrAttributes" metadata can't cover the latter one.
The problem of my approach is that it uses reflection to access an internal type, which could possibly break in the future if EF6 changes its implementation. And reflection is ugly anyway.

I verified that both "[Column(TypeName=)]" and "ModelBuilder.Entity().HasColumnType()" could be covered by my approach, but "ClrAttributes" metadata can't cover the latter one.
The problem of my approach is that it uses reflection to access an internal type, which could possibly break in the future if EF6 changes its implementation. And reflection is ugly anyway.

@lewischeng-ms

This comment has been minimized.

Show comment
Hide comment
@lewischeng-ms

lewischeng-ms Jan 22, 2016

Contributor

Close first. Will send another one later.

Contributor

lewischeng-ms commented Jan 22, 2016

Close first. Will send another one later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment