動くコード図鑑技術記事現場の渡り方キャリア論すべての記事About
C#

JsonExceptionが出た場合は下記をする。

出典: Asp.NetCoreApiのModel外部参照でNullを防ぐならIncludeを使え!JsonExceptionが出た場合は下記をする。

JsonExceptionが出た場合は下記をする。 (csharp)#7cf68e77babf
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddDbContext<DemoContext>(opt => opt.UseInMemoryDatabase("includeTest"));
            services.AddControllers().AddNewtonsoftJson(opt =>
                opt.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore);
 
            var options = new DbContextOptionsBuilder<DemoContext>().UseInMemoryDatabase(databaseName: "includeTest").Options;
            using (var context = new DemoContext(options))
            {
                AddTestData(context);
            }
        }
▸ この snippet は実行結果未収録
▸ 実行結果は未収録です
  • id: #7cf68e77babf
  • lines: 14
  • extracted: 2026-06-10

Source収録記事

この snippet は記事の「JsonExceptionが出た場合は下記をする。」セクションに登場する。コードの前後の文脈・ハマりどころの解説は記事本文で。

同じ記事から

4
図鑑トップ