Hi, I am using the FirstOrDefaultAsync method but the foreignkey table is null. Also does not allow to define Include in FirstOrDefaultAsync method. I will be glad if you help me
4 Answer(s)
-
0
Can you give more information about your issue and share some code to show that what you are trying to achieve and what exactly occurs?
-
0
I have two tables named QWorkspace and QWorkspaceGroup. And there is a foreignkey link between these two tables. (QWorkSpace (Id) ->QWorkSpaceGroup (QWorkSpaceId)
I'm pulling a record from the table with the code below.
QWorkSpace qWorkSpace = await _qWorkSpaceRepository.FirstOrDefaultAsync(e => e.Id == input.QWorkSpaceId);
When I call the table as qWorkSpace.QWorkspaceGroup, it is null.
-
0
Hi,
I think you can do it like this;
await _qWorkSpaceRepository.GetAll().Include(x => x.WorkspaceGroups).FirstOrDefaultAsync()
-
0
Thanks @ismcagdas