Posts

Showing posts with the label Efcore

Randomly Return Rows in EFCore with Postgresql

Currently working on a random list motorcycles to display on my front. At the moment don't have any priority listening on my site for clients other than the list of bikes I'm trying to sell personally as a source of income. For now this is what I did and its just these two parts to get things going.

something.OrderBy(r =>Guid.NewGuid()).Take(3) If you don't already have the extension this command will check and install for you.

CREATE EXTENSION IFNOTEXISTS"uuid-ossp";

Entity Framework: ToListAynsc & WhereAsync

When upgrading aspnet mvc applications I like to take a look on how I can convert the api's to async. This sometimes is really easy but as things get more complex my queries do as well. So this is a list of ways you can form a where clause on top your async but note not all solutions take advantage of it.
Notes on EFCore Entity Framework Core provides a set of asynchronous extension methods that can be used as an alternative to the LINQ methods that cause a query to be executed and results returned. Examples include ToListAsync(), ToArrayAsync(), SingleAsync(), etc. There are not async versions of LINQ operators such as Where(...), OrderBy(...), etc. because these methods only build up the LINQ expression tree and do not cause the query to be executed in the database. https://codereview.stackexchange.com/questions/32160/filtering-a-collection-by-an-async-resultFiltering a collection by an async result, built an extension method called WhereAsync.publicstatic async Task<IEnumerable…

PostGreSql and EFcore: Cheatsheet