0

I have table A, B, C,D.

Table D have forgienKey relationship columns(A1,B1,C1) with table A, B, C and Column C1 in table D is nullable column, because of it While loading table D using Include() nullable column row got skipped as below enter image description here

_context.Entry(F).Collection(x=>x.D).Query().Include(x=>x.A).Include(x=>x.B).Include(x=>x.C).Load();

I could able to get value for Id's 1,3,4 using above Query but full row ID 2, 5 is not in the collection list because of the null value.

If C1 has null value I should get remaining column information. Help needed plz

whoami
  • 83
  • 1
  • 2
  • 7
  • Please can you reword this as it does not make much sense. Its not clear what the issue is and what you're trying to achieve. – Kieran Devlin Aug 20 '20 at 12:41

1 Answers1

0

The most obvious reason for me, why your data for some of the C columns are not coming is because the Include method which you are using, underneath is acting as join operations between tables, and as you know "join" will not bring results for two tables if they don't match with PK->FK relations.

One of the suggestions here is to call the SQL Stored Procedure.

Another suggestion is to use a kind of similar approach to LEFT OUTER JOIN using LINQ.
Here is an excellentemphasized text post about how to do that.

Arsen Khachaturyan
  • 7,904
  • 4
  • 42
  • 42