Skip to content

Instantly share code, notes, and snippets.

View shahabganji's full-sized avatar
:octocat:
Coding ...

Shahab - Saeed Ganji shahabganji

:octocat:
Coding ...
View GitHub Profile
@shahabganji
shahabganji / Book.cs
Last active March 13, 2022 15:41
EfCore-Array-Of-String-Sample
public sealed class Book
{
private List<string> _tags;
private Book()
{
_tags = new List<string>();
}
public Book(string name)
{
@shahabganji
shahabganji / IHaveTrackingDates.cs
Last active January 2, 2022 17:24
Explore Shadow Properties in EF Core
public interface IHaveTrackingDates { }
public class Author : ICanBeSoftDeleted , IHaveTrackingDates
{
// omitted code
}
@shahabganji
shahabganji / ICanBeSoftDeleted.cs
Last active January 2, 2022 15:29
Explore Global Query Filters in EF Core
public interface ICanBeSoftDeleted
{
bool IsDeleted{ get; set;}
}
public class Author : ICanBeSoftDeleted
{
// omitted code
}
@shahabganji
shahabganji / alter-table.sql
Last active January 2, 2022 15:06
Ensure Uniqueness of Nullable Columns
ALTER TABLE dbo.Employee
DROP Constraint UQ_Employee_SSN
GO
ALTER TABLE dbo.Employee
ADD SSN_CMPTD AS
CASE
WHEN SSN IS NOT NULL
THEN SSN
@shahabganji
shahabganji / configuration-provider.cs
Last active January 2, 2022 14:37
Blog: Custom Configuration Providers in ASP.NET Core
public class SqlServerConfigurationProvider : ConfigurationProvider , IDisposable
{
private readonly SqlServerConfigurationSource _configurationSource;
public SqlServerConfigurationProvider(SqlServerConfigurationSource configurationSource)
{
_configurationSource = configurationSource;
}
public override void Load()
@shahabganji
shahabganji / account-login.cs
Last active January 2, 2022 11:41
Sample codes for the blog post: Generate/Validate JSON Web Tokens(JWT) in ASP.NET Core
var securityKey = new SymmetricSecurityKey(
Encoding.UTF8.GetBytes("7h!$S40u1d83@$7r0n9P@5$Word"));
var header = new JwtHeader(
new SigningCredentials(
securityKey,
SecurityAlgorithms.HmacSha512Signature
));
var claims = new[]
{
@shahabganji
shahabganji / Dockerfile
Created September 27, 2019 18:31
DockerizeAurleia
# use latest version of nodejs
FROM node:lts-alpine
# install aurelia-cli to build the app & http-server to serve static contents
RUN npm i -g http-server
RUN npm i -g aurelia-cli
# set working directory to app, henceforth all command will run inside this folder
WORKDIR /app
@shahabganji
shahabganji / actions.ts
Last active March 10, 2019 08:38
Leverage Services
import { IState } from "./state";
import { IContact } from "contacts/models/contact";
const selectContactAction = (state: IState, selectedContact: IContact) => {
const new_State = Object.assign({}, state);
new_State.contacts.selected = selectedContact;
return new_State;
@shahabganji
shahabganji / IdentityServerConfiguration.cs
Last active October 22, 2018 08:59
Aurelia + IdentityServer4
public static class IdentityServerConfiguration
{
public static IEnumerable<IdentityResource> IdentityResources =>
new List<IdentityResource> {
new IdentityResources.OpenId() ,
new IdentityResources.Profile()
};
public static IEnumerable<ApiResource> ApiResources =>
new[] {