Skip to content

Instantly share code, notes, and snippets.

@danielplawgo
danielplawgo / ConfigureAudit1.cs
Created February 14, 2019 14:32
Konfiguracja Audit z Entity Framework Plus
private Audit ConfigureAudit()
{
var audit = new Audit();
audit.CreatedBy = UserName;
audit.Configuration.Exclude<Product>();
return audit;
}
@danielplawgo
danielplawgo / query1.sql
Last active February 28, 2019 04:51
Temporal Tables - Historia zmian w SQL Server
CREATE TABLE dbo.Products
(
[Id] int IDENTITY(1,1) PRIMARY KEY,
[Name] nvarchar(250) NOT NULL,
[Description] varchar(max) NULL,
[ValidFrom] datetime2 (2) GENERATED ALWAYS AS ROW START,
[ValidTo] datetime2 (2) GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (ValidFrom, ValidTo)
)
WITH (SYSTEM_VERSIONING = ON (HISTORY_TABLE = dbo.ProductsHistory));
@danielplawgo
danielplawgo / AddDescriptionToProduct.cs
Last active March 4, 2019 14:38
Temporal Table i Entity Framework
public partial class AddDescriptionToProduct : DbMigration
{
public override void Up()
{
AddColumn("dbo.Products", "Description", c => c.String());
//AddColumn("dbo.ProductsHistory", "Description", c => c.String());
}
public override void Down()
{
@danielplawgo
danielplawgo / AddOrder.cs
Created March 11, 2019 05:25
Interceptory w Entity Framework
public partial class AddOrder : DbMigration
{
public override void Up()
{
CreateTable(
"dbo.Orders",
c => new
{
Id = c.Int(nullable: false, identity: true),
Number = c.String(),
@danielplawgo
danielplawgo / Counter.cshtml
Created March 17, 2019 07:44
Blazor - frontend w C#
@page "/counter"
<h1>Counter</h1>
<p>Current count: @currentCount</p>
<button class="btn btn-primary" onclick="@IncrementCount">Click me</button>
@functions {
int currentCount = 0;
@danielplawgo
danielplawgo / BaseModel.cs
Created March 25, 2019 07:25
Filtrowanie w Entity Framework Plus
public class BaseModel
{
public BaseModel()
{
IsActive = true;
}
public int Id { get; set; }
public bool IsActive { get; set; }
@danielplawgo
danielplawgo / WithCache.cs
Created March 29, 2019 05:19
Cache oraz Future z EF Plus
public class CacheDemo
{
public void Run()
{
WithCache();
}
private void WithCache()
{
using (var db = new DataContext())
@danielplawgo
danielplawgo / CSharp1.cs
Created May 21, 2019 07:11
Nowy switch w C# 8.0
class OperationDemo
{
public void Run()
{
var expression = new Expression()
{
Arg1 = 10,
Arg2 = 5,
Operator = "/"
};
@danielplawgo
danielplawgo / FetchData.razor
Created May 25, 2019 04:26
Blazor użycie Web API
@page "/fetchdata"
@inject IWeatherForecastService Service
<h1>Weather forecast</h1>
<p>This component demonstrates fetching data from the server.</p>
@if (forecasts == null)
{
<p><em>Loading...</em></p>
@danielplawgo
danielplawgo / FetchData.razor
Created May 28, 2019 04:18
Blazor JavaScript Interop
@page "/fetchdata"
@using CsvHelper
@using System.IO
@using System.Text
@inject IWeatherForecastService Service
@inject IFileService FileService
<h1>Weather forecast</h1>
<p>This component demonstrates fetching data from the server.</p>