Home > Net >  Controller returns in.net core web API association class displayed when {}
Controller returns in.net core web API association class displayed when {}

Time:07-04

visual studio 2019

the.net Core 3.1

the web API

enter the following code

The  [HttpGet (& # 34; test & # 34;)]Public ActionResult TestGet () {Var x & # 61; New SelectObject ();X.L Abel & # 61; & # 34; The test & # 34;;X.V alue & # 61; & # 34; & # 34; 123456;Var y & # 61; New SelectObject2 ();Y.n ame & # 61; & # 34; Test2 & # 34;;Y.o bj & # 61; x;Return Ok (x);}  

you can return to normal

The  {& # 34; The value & # 34; : & # 34; 123456 the & # 34; .& # 34; The label & # 34; : & # 34; The test & # 34;}  

if the code returns the object x to y & # xff0c; Is a relationship of object & # xff0c; The code below

The  [HttpGet (& # 34; test & # 34;)]Public ActionResult TestGet () {Var x & # 61; New SelectObject ();X.L Abel & # 61; & # 34; The test & # 34;;X.V alue & # 61; & # 34; & # 34; 123456;Var y & # 61; New SelectObject2 ();Y.n ame & # 61; & # 34; Test2 & # 34;;Y.o bj & # 61; x;Return Ok (y);//x into y}  

it returns the result becomes a null object

The  {}  

this is what happened & # xff0c; Which master to counteract the & # xff1f;

  •  Tags:  
  • Related