![]() ![]() It’s ready to run without any modifications. The best thing is – we can take this SQL with copy and paste to SQL Server Management Studio (SSMS) or some other database tool to investigate the query closer. When running the code in debug mode and checking the value of queryString variable we can see nice formatted SQL in Text Visualizer window. Public HomeController( MyDbContext dataContext) Private readonly MyDbContext _dataContext I was a bit clever when writing the query – notice how I used variable called prefix in LINQ expression. I injected my DbContext to HomeController and in Index() action I wrote a query to see what ToQueryString() method returns. Public MyDbContext( DbContextOptions options) : base( options) I added just few entities and primitive DbContext to try out how ToQueryString() extension method works. ![]() I created new ASP.NET Core web application project with latest Visual Studio 2019 Preview and connected EF Core to one of my existing databases. NET Core 5.0 and EF Core 5.0 are both in Preview and things may change in future versions of EF Core 5.0. This blog post shows how ToQueryString() method works. In some means it’s similar to ToTraceString() method of Entity Framework. This method is called ToQueryString() and it returns provider-specific SQL without connecting to database server. Entity Framework Core 5.0 comes with SQL-based brother to ToString() method for LINQ-queries. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |