Skip to content

Instantly share code, notes, and snippets.

View joakimriedel's full-sized avatar

Joakim Riedel joakimriedel

View GitHub Profile
@joakimriedel
joakimriedel / Program.cs
Created March 30, 2022 09:58
EF Core bug: Multiple counts in one select
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace EfCoreBug
{
class Program
@joakimriedel
joakimriedel / Program.cs
Last active March 24, 2022 09:41
TPH Concat bug with EF Core 6
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace EfCoreBug
{
class Program
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace EfCoreBug
{
class Program
@joakimriedel
joakimriedel / svgoLoader.ts
Created September 30, 2021 14:50
Plugin for svgo to set fill to currentColor
import svgToMiniDataURI from "mini-svg-data-uri";
import type { Plugin } from "rollup";
import fs from "fs";
import { optimize, OptimizeOptions } from "svgo";
type PluginOptions = { noOptimize?: boolean; svgo?: OptimizeOptions };
//TODO: remove this once https://github.com/vitejs/vite/pull/2909 gets merged
export const svgLoader: (options?: PluginOptions) => Plugin = (
options?: PluginOptions
@joakimriedel
joakimriedel / SvgIcon.vue
Last active June 28, 2022 20:41
Vue component for SVG icons using Vue 3, async import using Vite, and Typescript strict typings
<!-- This script for defining icon sources and type could be put in external ts file -->
<script lang="ts">
/** define all the icons that we want to make available here */
const iconSources = {
signin: () =>
import("@fortawesome/fontawesome-free/svgs/solid/sign-in-alt.svg"),
signout: () =>
import("@fortawesome/fontawesome-free/svgs/solid/sign-out-alt.svg"),
plus: () => import("@fortawesome/fontawesome-free/svgs/solid/plus.svg"),
};
@joakimriedel
joakimriedel / !typed mappers (mapGetters, mapActions, mapMutations, mapState) for vuex 4 and vue 3.md
Last active May 9, 2024 14:40
Strictly typed mappers for vuex 4 and vue 3 using Typescript 4.4+

Vuex 4 is a great companion to Vue 3, but Vuex is falling behind on Typescript support. While waiting for better typing support in Vuex 5 or using Pinia, this wrapper might help.

Using this wrapper will correctly infer arguments and return types on your state, actions, getters and mutations.

It works both within your store(s) and any Vue components where you use the mapActions, mapState, mapGetters or mapMutations helpers from Vuex.

No more any will help you find many errors at compile-time!

@joakimriedel
joakimriedel / EfCoreBugExpression.csproj
Last active September 12, 2019 12:03
Ef Core 3.0 Expression Bug
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<!--<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.6" />
@joakimriedel
joakimriedel / AssertRepro.csproj
Created August 9, 2019 20:48
Assert in SpillSequenceSpiller
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.6" />
@joakimriedel
joakimriedel / EfCoreBugSelectMany.cs
Created October 11, 2018 08:29
SelectMany with TPH and OfType throws System.ArgumentException
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace EfCoreBugSelectMany
@joakimriedel
joakimriedel / EFCoreBug2.cs
Created September 7, 2018 09:09
EF Core bug with AsQueryable and expression filter
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace EfCoreBug2