I am trying to shape HTTP GET request where entity wall and some of its parent table(User) rows are displayed. I succeded getting the whole parent row, but I am struggling with select statement where I Want to choose which rows and values I want in my response.
[HttpGet]
public async Task<ActionResult<IEnumerable<Wall>>> GetWalls()
{
return await _context.Walls
.Include(p=>p.User)
.ToListAsync();
}
My response looks like this :
{
"wallID": "46d7389f-2dcd-4b52-b4c0-32e7bbf5af24",
"wallName": "erfnoerng",
"dateCreated": "2020-07-31T11:53:21.9217551",
"dateUpdated": null,
"userID": "274eed93-fedf-4825-9c11-deb1e7678b99",
"user": {
"fullName": "Phil Hearing",
"wall": [],
"id": "274eed93-fedf-4825-9c11-deb1e7678b99",
"userName": "philcuAdmin",
"normalizedUserName": "PHILCUADMIN",
"email": "phil@gmail.com",
"normalizedEmail": "PHIL@GMAIL.COM",
"emailConfirmed": false,
"passwordHash": "AQAAAAEAACcQAAAAECPcBzMuCBrvo5jfSvRC8htiBMcXY6uHPymLvLLpqTOQc0iiYO9mB7XS82O0f2OEkA==",
"securityStamp": "DCYN6LTUSAP3HSAD6ZEENPJ6CPZXCDAO",
"concurrencyStamp": "fb06525c-0bad-4f06-bbdd-8f4404097a54",
"phoneNumber": null,
"phoneNumberConfirmed": false,
"twoFactorEnabled": false,
"lockoutEnd": null,
"lockoutEnabled": true,
"accessFailedCount": 0
},
"groupATerms": null,
"groupBTerms": null,
"groupCTerms": null,
"groupDTerms": null,
"groupAConnections": null,
"groupBConnections": null,
"groupCConnections": null,
"groupDConnections": null
}
I would like to get only Username, email and fullName from parent table but I get error when I write .Select statement which says that Select does not exist in current context.