Skip to content
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

Conversion of types in queries #39

Open
asgerhallas opened this issue Nov 24, 2017 · 0 comments
Open

Conversion of types in queries #39

asgerhallas opened this issue Nov 24, 2017 · 0 comments

Comments

@asgerhallas
Copy link
Owner

Some types needs to be converted before being projected to a column in sql server. Say we have a property named Consumption of type Energy, which can be converted to kWh like:

x.Consumption.KWh

To project this while still having a reasonable name for the column we can override the name:

.With(nameof(Consumption), x => x.Consumption.KWh)

But then when querying this we can no longer just use x.Consumption, but have to use the .Column() extension method like:

from x in xs
where x.Column<decimal>(nameof(x.Consumption)) == 100
select x

We would like to be able to be able to write:

from x in xs
where x.Consumption == 100.KWh()
select x

To do that we have to know - in the linq provider - that the projection (on the left) has been converted and then apply the same conversion to the value (on the right) before building the sql. I think the config could look like this:

.With(x => x.Consumption, x => x.KWh)

This could maybe also be used to fix issue #30 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant