Skip to content

Translate DateOnly.DayNumber subtraction #3194

@iPilot

Description

@iPilot

Introduction

Well, it's pretty weird example, but whatever. As soon as there is a translation DateOnly to date type it could be useful to allow to translate DateOnly.DayNumber - DateOnly.DayNumber to date - date. Luckily, both operations return integer number as a result.

Pros

  • Return the difference between two DateOnly columns directly from database
  • Align the translation behavior with DateTime - DateTime and DateTimeOffset - DateTimeOffset
  • Allow ordering by the substruction result directly by the database engine

Cons

Unfortunately, DateOnly type itself does not support a substruction operator, only using DayNumber property and code written in a such way looks a little bit clunky and unobvious. Considering this, the translation could be implemented as an extension for EF.DbFunctions class.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions