public async Task UpdatesNpgSql() { var toUpdate = NpgSqlIds.Take(2) .ToDictionary(key => key, value => DateTime.UtcNow.AddDays(value + 1)); using (var db = new postgresContext()) { var result = await db.Efcoretest.BulkUpdateAsync(toUpdate.Select(x => x.Key), id => new Efcoretest { Modifieddate = toUpdate[id] }); Assert.Equal(toUpdate.Count, result); } using (var db = new postgresContext()) { var updated = await db.Efcoretest .Where(x => toUpdate.Select(y => y.Key).Contains(x.Id)) .ToListAsync(); Assert.Equal(toUpdate.Count, updated.Count); foreach (var u in updated) { Assert.Contains(u.Id, toUpdate.Select(x => x.Key)); var expected = toUpdate[u.Id]; var actual = u.Modifieddate; Assert.Equal(expected.ToString("d"), actual.ToString("d")); } } }
public async Task JoinsByPrimaryKeyNpgSql() { var expectedIds = NpgSqlIds.Take(5).ToList(); List <int> actualIds; using (var db = new postgresContext()) { actualIds = await db.Efcoretest .Join(expectedIds) .Select(e => e.Id) .ToListAsync(); } Assert.Equal(expectedIds.Count, actualIds.Count); foreach (var expected in expectedIds) { Assert.Contains(expected, actualIds); } }