Skip to content

Instantly share code, notes, and snippets.

View QuantumHive's full-sized avatar

QuantumHive QuantumHive

  • The Netherlands
View GitHub Profile
@QuantumHive
QuantumHive / Program.cs
Created October 16, 2017 19:41
simpleinjector conditional register example
using System;
using System.Collections.Generic;
using System.Linq;
using SimpleInjector;
namespace ConsoleApp2
{
internal class Program
{
private readonly IQueryHandler<Query, PaginatedResult<Model>> handler;
@QuantumHive
QuantumHive / MyDbContext.cs
Created June 21, 2017 10:21
Entity Framework 6: Clone object except ID
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
namespace ConsoleApplication1
{
public class MyDbContext : DbContext
{
public MyDbContext()
: base("name=MyDbContext")
{
@QuantumHive
QuantumHive / ForeignKeyMappingExample.cs
Created November 20, 2016 22:46
This example demonstrates how to map a non-conventional foreign key with Entity Framework Fluent API without using a scalar property for the foreign key
public class MyContext : DbContext
{
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
/* Creates:
* Table Foo with two columns: Id (PK) and FK_BarId (FK)
* Table Bar with one column: Id (PK)
*/
modelbuilder.Entity<Foo>()
.HasRequired(m => m.Bar)