stream:// .net core


July 28, 2020
  142
[DISPLAY_ULTIMATE_SOCIAL_ICONS] Entity Framework Core (EF) converts expressions into SQL at runtime. In earlier versions, it was straight forward to get the SQL. In Entity Framework Core 3, you must access the SQL using ILogger. This article explains how to access the SQL generated and gives some example code to access the output of queries made behind the scenes. This article works with Entity Framework Core 3. Note: Microsoft is about to release Entity Framework Core 5 soon. This version will have an easier method to get at the SQL. This is the interface method. Many developers may feel uncomfortable if they do not know what SQL EF executes behind the scenes. There's a good reason for this! Expressions may not map on to SQL very easily. You may end up executing SQL that doesn't take advantage of indexes, or the expression may end up filtering records after the data was selected from the database. In older versions of EF you could use ToTraceString()but this no longer exists in EF Core 6. There may even be other reasons to access the SQL. Perhaps your want to convert EF expressions to SQL. This is all possible in EF Core. Grab the full sample here. The Basics The key to making entity framework log SQL queries is to provide it with a logging factory: optionsBuilder.UseLoggerFactory(_loggerFactory); And, the factory must have a filter like so: var loggerFactory = LoggerFactory.Create(builder => { builder .AddFilter((category, level) => category == DbLoggerCategory.Database.Command.Name && level == LogLevel.Information); }); That's it. If you add console logging, SQL will be logged to the console when the SQL executes. var loggerFactory = LoggerFactory.Create(builder => { builder .AddConsole((options) => { }) .AddFilter((category, level) => category == DbLoggerCategory.Database.Command.Name && level == LogLevel.Information); }); This is an example query: using (var ordersDbContext = new OrdersDbContext(loggerFactory)) { var orderLines = ordersDbContext.OrderLines.Where(o => o.Id == Guid.Empty).ToList(); orderLines = ordersDbContext.OrderLines.ToList(); } This is the console output: info: Microsoft.EntityFrameworkCore.Database.Command[20101]Executed DbCommand (3ms) [Parameters=[], CommandType='Text', CommandTimeout='30']SELECT COUNT(*) FROM sqlite_master WHERE type = 'table' AND rootpage IS NOT NULL;info: Microsoft.EntityFrameworkCore.Database.Command[20101]Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']SELECT o.Id, o.Count, o.ItemFROM OrderLines AS oWHERE o.Id = '00000000-0000-0000-0000-000000000000'info: Microsoft.EntityFrameworkCore.Database.Command[20101]Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']SELECT o.Id, o.Count, o.ItemFROM OrderLines AS o Incidentally, it looks as though the where clause is not parameterized. Is this a security hole in Entity Framework Core for SQLite? Here is some further documentation on this approach. Getting More Detail You may need more detail. Or, you may want to use EF to generate SQL for some reason. You can achieve that with this code. This is an implementation of ILogger that will allow you to hook into an action when SQL runs. public class EntityFrameworkSqlLogger : ILogger { #region Fields Action<EntityFrameworkSqlLogMessage> _logMessage; #endregion #region Constructor public EntityFrameworkSqlLogger(Action<EntityFrameworkSqlLogMessage> logMessage) { _logMessage = logMessage; } #endregion #region Implementation public IDisposable BeginScope<TState>(TState state) { return default; } public bool IsEnabled(LogLevel logLevel) { return true; } public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter) { if (eventId.Id != 20101) { //Filter messages that aren't relevant. //There may be other types of messages that are relevant for other database platforms... return; } if (state is IReadOnlyList<KeyValuePair<string, object>> keyValuePairList) { var entityFrameworkSqlLogMessage = new EntityFrameworkSqlLogMessage ( eventId, (string)keyValuePairList.FirstOrDefault(k => k.Key == commandText).Value, ...
July 27, 2020
  182
As I am getting myself up to date with the modern C# language features, I'd like to share what feels...
July 22, 2020
  201
In this article I'll describe how to modernise your .NET Framework projects for .NET Core, the .NET Standard and .NET 5, which is planned to be released this year.
July 20, 2020
  200
[DISPLAY_ULTIMATE_SOCIAL_ICONS] Blazor is a new Single Page Application (SPA) technology by Microsoft. It is a comparable technology to React, Angular, and Vue.js but uses C# instead of JavaScript. It brings C# to the world of SPAs and challenges traditional web apps frameworks such as ASP .NET Web Forms and ASP .NET Core MVC for building web apps. This article discusses the choice between SPAs and traditional web apps and explains the difference between server-side and client-side rendering.  What are Traditional Web Apps? Traditional web apps are apps that have little or no client-side processing. HTML is rendered server-side and passed to the browser. They mostly center around static text and filling out forms, and most interactions require a full page refresh. Browsers send data to the server via HTML forms, and the server handles the processing. Technologies like ASP (including all flavors such as classic, and MVC) and  PHP facilitate the transfer of data between the client and server and handle server-side processing. They mix server-side and client-side logic by allowing developers to declare the client-side UI with HTML alongside code that runs on the server. Forms can be developed quickly with no separation between APIs and front-end code. Traditional web app workflow typically presents the user with a form, a submit button, and a full-page response is received from the server after they click the button. The result is usually a disjointed and unsatisfactory user experience. In the approach, APIs are typically not made as first-class citizens. Traditional web apps usually require developers to build a separate set of APIs for consumption by 3rd parties or other apps such as phone apps. It often leads to code duplication. ASP Web Forms is an example of a traditional web app technology. It is possible to build SOAP Web Services, but it does not support designing modern Web APIs. Microsoft introduced ASP.NET Core for flexibility. It supports everything from modern Web APIs to traditional web apps. The MVC flavor of ASP.NET Core is a framework for building traditional web apps. What are Single Page Apps? Single page apps are web-based apps where UI is dynamically modified based on data transfer with the server via API calls. SPAs render the HTML DOM on the client-side. They are analogous to native phone or desktop apps. The server generally transfers all HTML, JavaScript, and CSS or WebAssembly code at the beginning of the session and does not transfer these as part of subsequent API calls. The browser modifies the HTML DOM instead of requesting the full HTML from the server. Ajax was the first step toward SPA frameworks. The approach became popular in the early 2000s. It uses JavaScript to call server-side APIs and so on to allow for asynchronous partial page refreshes. It provides a radical user experience improvement over traditional web apps. The browser can perform partial updates of data on the screen, and there is no HTML transfer on each call. Many traditional web apps started partially integrating Ajax. Developers added Web services to the back-end, and JavaScript code was served to the browser to call the endpoints. It meant that most traditional apps ended up becoming a mixture of server-side HTML rendering and client-side DOM manipulation with JavaScript.  JavaScript module bundlers such as webpack simplify the process of building pure JavaScript applications. They bundle an application in a similar way to a compiled native application. When coupled with frameworks such as Vue.js, Angular, and React, SPAs are easy to build and deploy. Developers build APIs as first-class citizens in parallel with SPA front-ends. Native app developers and 3rd parties can reuse the APIs so that all applications in the ecosystem depend on the same APIs. Modern systems frequently target platforms such as iOS and Android, so it is critical to reuse back-end infrastructure as much as possible.  What is Blazor? Blazor is a SPA framework that uses compiled C# to manipulate the HTML DOM instead of JavaScript. Blazor allows for server-side or client-side hosting models, but in either case, the browser manipulates HTML DOM client-side. The app remains a SPA app because the user does not experience full page refreshes. Non-Blazor SPA frameworks may have a steep learning curve for C# programmers. Typescript has some similarities to C#, but the programming paradigm is quite different. Bla...
July 14, 2020
  166
We will discuss in detail, Globalization and Localization in ASP.NET Core Application and go through various approaches on changing the Culture of the App.
July 13, 2020
  206
I was first introduced to TPL Dataflow when I watched Stephen Toub talk about it on the MSDN Channel9 Developers Channel. I’ve had very few chances to use the TPL Dataflow library in my professional work, but when I have, it’s been simple and clean to implement. All code is available on my public GitHub where I’ve provided samples for .NET Core 3.0. Why Would I Use TPL Dataflow? If you find yourself having to process a lot of data concurrently in a variety of ways in a single application, you really should take a look.
July 11, 2020
  499
I create the CoronaClient project implement the domain layer. I also create an implementation of our ICoronavirusCountryService using a Coronavirus API. To c...
July 11, 2020
  178
Today the AWS Elastic Beanstalk service extends its .NET support with the creation of the new .NET Core on Linux platform. This new platform version makes it easy to get ASP.NET Core applications deployed to AWS quickly for either a dev stack or a full production environment including enhanced health, patching, autoscaling, and rolling deployments. […]
July 10, 2020
  160
Introducing the .NET Guide &#8211; Tutorials, Tips &#038; Tricks for .NET, Rider, and ReSharper &#8211; .NET Tools Blog | JetBrains

Hot Vacancies

Middle / Senior Full-Stack .NET developer

Springdel
.NET Core

The project aims to change the shape of the healthcare market making it easier to find affordable services.

Middle .NET Developer

MyCredit
.NET Core

MyCredit is a space with a huge soul and a pleasant atmosphere. We are a product company, a leader in the microcredit market with 4 years of experience! We are included in the Top 3 FinTech and e-commerce projects of the country! We believe in the potential of each person, in his talent and desire to develop, and we also believe in respect and support. Therefore, we have assembled a team of guys who share our faith and go forward with us. If all this is about you, be sure to read it to the end! Our team of professionals is rapidly gaining momentum, and now we are looking for a Middle .NET Developer who will be interested in working with BPM Corezoid.

Lead .NET Developer

MyCredit
.NET Core

MyCredit is a space with a huge soul and a pleasant atmosphere. We are a product company, a leader in the microcredit market with 4 years of experience! We are entering the Top 3 FinTech and e-commerce projects of the country! We believe in the potential of each person, in his desire to develop, and we also believe in respect and support. Therefore, we have assembled a team of guys who share our faith and go forward with us. If all this is about you, be sure to read it to the end! Our team of professionals is rapidly gaining momentum, and now we are looking for a Lead .NET Developer to work on a high-load project.

Backend Developer

Oneview Healthcare
.NET Core

Oneview Healthcare is a global company, working with hospitals and senior care facilities around the world.

Senior .NET Developer

.NET Core

We are looking for Senior .Net Developer to join Kiev team. You will be part of a team of strong, result-oriented professionals developing new generation tasks management, people management, learning platform.