zompinc / efcore-extensions

Provides window (analytics) functions and binary functions for EF Core. Providers: SQL Server, SQLite, Postgres.
MIT License
60 stars 6 forks source link

Add Support for Window Functions: Lag/Lead #16

Closed Deus3526 closed 6 months ago

Deus3526 commented 6 months ago

As indicated in the title, I am requesting support for the window functions Lag and Lead.

I am working on a side project related to stock trading. In this project, I need to perform condition-based filtering. For example, I might want to filter cases where today's lowest stock price is greater than the highest price of the previous trading day. To implement such queries in C#, I require the support of Lag/Lead/STDEVP functions. Without these functions, I believe I would be limited to using raw SQL commands, which is not ideal for my workflow.

Thank you to the development team for your efforts and contributions to the EF window functions package. I've noticed a lack of extensions in this area, making your work incredibly important for developers like myself. Such a package offers greater flexibility and efficiency, which is particularly crucial in my projects. Once again, thank you for your hard work and innovation.

virzak commented 6 months ago

@Deus3526,

Thanks for the kind words. These functions will be implemented in the near future!

virzak commented 6 months ago

Lag and Lead are implemented in a separate branch and ready to be merged.

Can you try it out and see if the API is user friendly and self-explanatory? I'm specifically interested in feedback respect / ignore nulls.

Nuget package to link to is here.

Deus3526 commented 6 months ago

I've installed the package and tested the Lag and Lead features. It seems to work well and meets my needs. The Lag/Lead API can be used in the same way as other window functions. Thanks!"

virzak commented 6 months ago

Version 8.0.10 has Lead and Lag. Will look into STDEVP separately soon.