Add support of Futures
See original GitHub issueHi,
It would be a great value for the library to have Future support. What I mean by Future is the possibility to batch multiple Sql queries in a single request to the server and parse the result one time.
You can see a practical case in Ayend’s blog, But nowadays it’s more important to have such a feature.
As many applications, we have a Saas application deployed on the Cloud, a Single Page Application :
- When the application first loads, it fetchs a lot of data from the server, just a bunch of Selects to get the current user name, the notifications, some elements on the dashboard, and other business elements etc… The Sql server is hosted in the cloud too, sometimes not the same Network than the server so there is a lot of firewall between the two. Without Future, we would need to send each request, wait for the result, parse the result, and then send the second request, during all this time Sql Server is in Idle mode ( Because of Session pooling, we won’t face TCP Warm up problem ).
- In our application, we follow UnitOfWork Pattern, at the beginning of the request we open a transaction, at the end of the request we flush all the Updates/Inserts/Deletes, that make a big request of many queries, a fire&forget query because we don’t read anything from this point, without Future, we would need to wait for each Update/Insert/Delete to finish to run the next one, and during this time Sql Server is in Idle mode.
- We have a SPA, so the reactivity of our application is directly related to the performance of each small webservice, and because we precalculate everything, the webservices will have just to fetch data from sql server. Think of it like a Dashbord showing a lot of data, User experience depends directly on the speed of fetching the data from the Sql Server and serving it to the App.
If we can do something like this that would be great :
public static List<Product> Search(string searchFor, int currentPage, int pageSize, out int totalRecords)
{
using (var db = new DbNorthwind())
{
var products = from p in db.Product
select p;
if (searchFor != null)
{
products = from p in products
where p.Name.Contains(searchFor)
select p;
}
var lTotalRecords = products.Future().Count(); // That would return a Lazy<int>
var ret = products.Skip((currentPage - 1) * pageSize).Take(pageSize).Future().ToList(); // That would return a Lazy<List<Product>>
totalRecords = lTotalRecords.Value; // At this moment the ret.Value will have also the value set.
return ret.Value;
}
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Futures in Stock Market: Definition, Example, and How to ...
Futures are financial contracts obligating the buyer to purchase an asset or the seller to sell an asset at a predetermined future date...
Read more >7 Tips Every Futures Trader Should Know
Here are seven strategies to help you improve your futures trading knowledge.
Read more >How to trade futures
Get specialized futures trading support. Have questions or need help placing a futures trade? Call our licensed Futures Specialists today at 877-553-8887.
Read more >Futures trading FAQ
Have a question on futures trading? We've got you covered with the most frequently asked futures questions and our expert answers.
Read more >Futures Trading: Everything You Need to Know
Futures trading is a way to speculate on or hedge against the future value of all kinds of assets, including stocks, bonds, and...
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 have API prototype which is more sophisticated and has to cover more functionality. But I don’t have time this year.
persons.Value
- will contain list andcount.Value
will have CountAnd how to insert graph of records:
db.CompleteDefer()
is not required if last call is not deferred.Library should understand that database provider support multiple record-sets and combine queries accordingly.
For Firebird it will be two separated database requests:
For SQL Server it will be one round trip to database, because we can store result of first insert into SQL variable.
@sdanyliv : Are there any news for a future support? The ef core extension has also a nice implementation. What I missed for all implementations is a kind of group, something like: