private static void Seed3595(Context3595 context) { var question = new Question3595(); var examInstance = new Exam3595(); var examInstanceQuestion = new ExamQuestion3595 { Question = question, Exam = examInstance }; context.Add(question); context.Add(examInstance); context.Add(examInstanceQuestion); context.SaveChanges(); }
public void GroupBy_with_uninitialized_datetime_projection_3595() { using (CreateScratch <Context3595>(Seed3595, "3595")) { using var context = new Context3595(); var q0 = from instance in context.Exams join question in context.ExamQuestions on instance.Id equals question.ExamId where instance.Id != 3 group question by question.QuestionId into gQuestions select new { gQuestions.Key, MaxDate = gQuestions.Max(q => q.Modified) }; var result = q0.ToList(); Assert.Equal(default, result.Single().MaxDate);
private static InMemoryTestStore CreateScratch <TContext>(Action <TContext> Seed) where TContext : DbContext, new() => InMemoryTestStore.CreateScratch( () => { using (var context = new TContext()) { Seed(context); } }, () => { using (var context = new Context3595()) { context.GetInfrastructure().GetRequiredService <IInMemoryStoreSource>().GetGlobalStore().Clear(); } });
private static InMemoryTestStore CreateScratch <TContext>(Action <TContext> Seed) where TContext : DbContext, new() => InMemoryTestStore.CreateScratch( () => { using (var context = new TContext()) { Seed(context); } }, () => { using (var context = new Context3595()) { context.GetService <IInMemoryStoreSource>().GetPersistentStore(DatabaseName).Clear(); } });