Skip to content

Instantly share code, notes, and snippets.

Avatar

Julie Lerman julielerman

View GitHub Profile
@julielerman
julielerman / Single vs First Logs EF Core
Last active Nov 4, 2016
EF Core 1.1 Preview Logs for Single & First Comparisons
View Single vs First Logs EF Core
**TEST #1: First() ****
Assert.IsInstanceOfType(_context.Samurais.First(s => s.Id == 1),typeof(Samurai));
COMPILING QUERY MODEL:
'(from Samurai s in DbSet<Samurai>
where s.Id == 1
select s)
.First()'
Optimized query model:
'(from Samurai s in DbSet<Samurai>
@julielerman
julielerman / Static Seed
Created Aug 3, 2016
Static class for seeding via EF, uses IServiceScopeFactory
View Static Seed
public static class Seeder
{
public static void Seedit(string jsonData, IServiceProvider serviceProvider)
{
List<WeatherEvent> events =
JsonConvert.DeserializeObject<List<WeatherEvent>>(jsonData);
using (var serviceScope = serviceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope())
{
var context = serviceScope.ServiceProvider.GetService<WeatherContext>();
if (!context.WeatherEvents.Any())
@julielerman
julielerman / config.js
Created Apr 22, 2016
config.js for aurelia app that is complaining about aurelia.globalResources is not a function after updating packages
View config.js
System.config({
defaultJSExtensions: true,
transpiler: "babel",
babelOptions: {
"optional": [
"es7.decorators",
"es7.classProperties",
"runtime"
]
},
@julielerman
julielerman / gist:ff55cd76b8af1cea5eb2
Last active Aug 29, 2015
trouble ...starts with a t and that rhymes with p
View gist:ff55cd76b8af1cea5eb2
//debugging I can see this db getting created in file explorer
//the savechanges throws every time (from a test or from app) with SQLite exception "SQL logic error or missing database"
using (var contextCreateDb = new BreweryContext())
{
//database exists seems to be working with current ef7 build but not delete yet
//if (contextCreateDb.Database.Exists()) {
// contextCreateDb.Database.Delete(); //but delete doesnt work yet ;)
// }