Skip to content

Instantly share code, notes, and snippets.

Diego Vega divega

Block or report user

Report or block divega

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@divega
divega / MyContext.cs
Last active May 31, 2019
Simple builder class for creating TVPs that work in .NET Core 1.0
View MyContext.cs
using Microsoft.EntityFrameworkCore;
namespace TvpSampleApp
{
public class MyContext : DbContext
{
public DbSet<Person> People { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
@divega
divega / ef6.2-issue275.cs
Last active May 23, 2017
Pattern to enable cached code first models in EF 6.2
View ef6.2-issue275.cs
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
namespace MyApplication
{
public class MyDbConfiguration : DbConfiguration
{
public MyDbConfiguration() : base()
{
this.SetModelStore(new DefaultDbModelStore(Directory.GetCurrentDirectory()));
@divega
divega / ef6.2-issue274.cs
Last active May 23, 2017
Pattern for configuring indexes in EF6.2
View ef6.2-issue274.cs
using System;
using System.Data.Entity;
namespace MyApplication
public class MyContext: DbContext
{
public DbSet<Person> People { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
@divega
divega / ef6.2-issue241.cs
Last active May 23, 2017
Pattern for using Like in LINQ in EF 6.2
View ef6.2-issue241.cs
var query = db.People.Where(p => DbFunctions.Like(p.Name, "w%"));
@divega
divega / ef6.2-issue165.cs
Last active Feb 11, 2019
Pattern to enable sequences in EF 6.2
View ef6.2-issue165.cs
System.Data.Entity.SqlServer.SqlProviderServices.UseScopeIdentity = false;
@divega
divega / EntityAndQuery.Program.cs
Created Jul 26, 2018
Mapping the same table to two objects
View EntityAndQuery.Program.cs
using Microsoft.EntityFrameworkCore;
using System.Linq;
namespace ConsoleApp33
{
class Program
{
static void Main(string[] args)
{
using (var context = new MyContext())
@divega
divega / Program.cs
Created May 31, 2019
Using a shared in-memory SQLite database in a test
View Program.cs
using System;
using System.Linq;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace EnsureCreatedSqliteInMemory
{
class Program
{
@divega
divega / SortWithJoin.cs
Created Nov 7, 2019
Sorting an array with the order of another array using LINQ's Join
View SortWithJoin.cs
using System;
using System.Linq;
namespace SortWithJoin
{
class Program
{
static void Main(string[] args)
{
var keys = new [] { 5, 7, 3, 2, 1, 4, 6, 9, 8 };
You can’t perform that action at this time.