コード例 #1
0
ファイル: QueryBugTest.cs プロジェクト: traveloka/efcore.pg
        public void Bug278()
        {
            using var _       = CreateDatabase278();
            using var context = new Bug278Context(_options);
            var actual = context.Entities.Select(x => new
            {
                Codes = x.ChannelCodes.Select(c => (ChannelCode)c)
            }).ToList()[0];

            Assert.Equal(new[] { ChannelCode.Code, ChannelCode.Code }, actual.Codes);
        }
コード例 #2
0
        public void Bug278()
        {
            using (var testStore = NpgsqlTestStore.CreateScratch())
                using (var context = new Bug278Context(Fixture.CreateOptions(testStore)))
                {
                    context.Database.EnsureCreated();
                    context.Entities.Add(new Bug278Entity {
                        ChannelCodes = new[] { 1, 1 }
                    });
                    context.SaveChanges();

                    var actual = context.Entities.Select(x => new
                    {
                        Codes = x.ChannelCodes.Select(c => (ChannelCode)c)
                    }).ToList()[0];

                    Assert.Equal(new[] { ChannelCode.Code, ChannelCode.Code }, actual.Codes);
                }
        }
コード例 #3
0
        public async Task Bug278()
        {
            using (var testStore = NpgsqlTestStore.CreateScratch())
                using (var context = new Bug278Context(new DbContextOptionsBuilder()
                                                       .UseNpgsql(testStore.Connection)
                                                       .Options))
                {
                    context.Database.EnsureCreated();
                    context.Entities.Add(new Bug278Entity {
                        ChannelCodes = new[] { 1, 1 }
                    });
                    context.SaveChanges();

                    var actual = await context.Entities.Select(x => new
                    {
                        Codes = x.ChannelCodes.Select(c => (ChannelCode)c)
                    }).FirstOrDefaultAsync();

                    Assert.Equal(new[] { ChannelCode.Code, ChannelCode.Code }, actual.Codes);
                }
        }