Showing posts with the label Postgresql

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.


Aspetcore: NLog with Postgresql

This Article is base ASP.Net Core 2 and the latest version of Nlog.

1. Install NLog and the Postgresql Package Using NuGet to install the package into your ASP.NET Core project: PM > Install-Package NLog.Web.AspNetCorePM > Install-Package Npgsql3. Register NLog Add in your Startup.cs  publicvoidConfigure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { ... env.ConfigureNLog("nlog.config"); ... // make sure Chinese chars don't fk up Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); //add NLog to ASP.NET Core loggerFactory.AddNLog(); //add NLog.Web app.AddNLogWeb(); }4. Add to Your Controller Add a logger object to your Controller. private readonly ILogger<YourController> _logger; Modify the constructor to use it publicYourController(ILogger<YourController> logger = null) { if (null != logger) { _logger = logger; } }5. Use Logging APIs Now, you can use the loggin…