public SakilaLiteFixture() { using (SakilaLiteContext context = new SakilaLiteContext()) { context.InitContext(); } }
public void OneTimeTearDown() { using (var context = new SakilaLiteContext()) { context.Database.EnsureDeleted(); } }
public void SakilaLiteTest() { using (SakilaLiteContext context = new SakilaLiteContext()) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); } }
public void ModelLevelQueryFilter() { using (SakilaLiteContext context = new SakilaLiteContext()) { Assert.Equal(584, context.Customer.Count()); Assert.Equal(599, context.Customer.IgnoreQueryFilters().Count()); } }
public void TearDown() { using (var context = new WorldContext()) context.Database.EnsureDeleted(); using (var context = new MyContext()) context.Database.EnsureDeleted(); using (var context = new SakilaLiteContext()) context.Database.EnsureDeleted(); }
public void ExplicitlyCompiledQueries() { using (SakilaLiteContext context = new SakilaLiteContext()) { var customer = _customerById(context, 9); Assert.Equal(9, customer.CustomerId); Assert.Equal("MOORE", customer.LastName); } }
public void OneTimeSetUp() { using (var context = new SakilaLiteContext()) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); context.PopulateData(); } }
public void LikeIntLiteralWithEscape() { using (var context = new SakilaLiteContext()) { var count = context.Actor.Count(o => EF.Functions.Like(o.ActorId, "!%", "!")); Assert.AreEqual(0, count); } }
public void LikeDateTimeLiteral() { using (var context = new SakilaLiteContext()) { var count = context.Actor.Count(o => EF.Functions.Like(o.LastUpdate, "%A%")); Assert.AreEqual(0, count); } }
public void DateDiffHour() { using (var context = new SakilaLiteContext()) { var count = context.Actor .Count(a => EF.Functions.DateDiffHour(a.LastUpdate, DateTime.Now) == 0); Assert.AreEqual(0, count); } }
public void ScalarFunctionMapping() { using (SakilaLiteContext context = new SakilaLiteContext()) { context.Database.ExecuteSqlInterpolated($"CREATE FUNCTION FilmsByActorCount(id SMALLINT) RETURNS INT RETURN (SELECT COUNT(*) FROM film_actor WHERE actor_id = id);"); var query = context.Actor.Where(c => SakilaLiteContext.FilmsByActorCount(c.ActorId) == 18).ToList(); Assert.That(query.Select(a => a.ActorId), Has.Exactly(1).Matches <short>(actorid => actorid.Equals(31))); Assert.That(query.Select(a => a.ActorId), Has.Exactly(1).Matches <short>(actorid => actorid.Equals(71))); } }
public void LikeFunction() { using (SakilaLiteContext context = new SakilaLiteContext()) { var query = context.Actor.Where(c => EF.Functions.Like(c.LastName, "A%")).ToList(); Assert.NotEmpty(query); foreach (Actor actor in query) { Assert.StartsWith("A", actor.LastName); } } }
public void ScalarFunctionMapping() { using (SakilaLiteContext context = new SakilaLiteContext()) { context.Database.ExecuteSqlCommand("CREATE FUNCTION FilmsByActorCount(id SMALLINT) RETURNS INT RETURN (SELECT COUNT(*) FROM film_actor WHERE actor_id = id);"); var query = context.Actor.Where(c => SakilaLiteContext.FilmsByActorCount(c.ActorId) == 18).ToList(); Assert.Collection <Actor>(query, e => { Assert.Equal(31, e.ActorId); }, e => { Assert.Equal(71, e.ActorId); } ); } }
public void ConvertToType() { using (var context = new SakilaLiteContext()) { var ls = new List <ActorTest>(); ls = context.Actor.OrderBy(a => a.ActorId).Select(b => new ActorTest { Number = Convert.ToInt32(b.ActorId), Value = Convert.ToString(b.LastUpdate), Text = b.FirstName, }).ToList(); Assert.IsNotEmpty(ls); } }