One-to-one navigation properties with value null
See original GitHub issueHello cloud-sdk-js,
I have a question concerning one-to-one navigation properties. Depending on the data they can be null although this is not specified in their type definition.
Example (@sap-cloud-sdk/core 1.39.0, @sap/cloud-sdk-op-vdm-business-partner-service 1.24.0):
const destination = getDestinationFromSomewhere();
const result = await BusinessPartner
.requestBuilder()
.getAll()
.execute(destination);
If customer/supplier is not maintained the corresponding one-to-one navigation properties toCustomer
and toSupplier
are null which does not match their type definition:
/**
* One-to-one navigation property to the [[Customer]] entity.
*/
toCustomer: Customer;
/**
* One-to-one navigation property to the [[Supplier]] entity.
*/
toSupplier: Supplier;
This may cause problems when using the result in the BusinessPartner.builder().fromJson
method because it would only accept Customer
/Supplier
or undefined
.
Could you please have a look at this?
Thanks in advance.
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (9 by maintainers)
Top Results From Across the Web
EF Core 3.1.4 Navigation property returning null in One-To ...
I am having a problem where a navigation property is always returning null in a One-to-One relationship in EF Core 3.1.4.
Read more >Relationships - EF Core | Microsoft Learn
The most common pattern for relationships is to have navigation properties defined on both ends of the relationship and a foreign key ...
Read more >Entity Framework Core One To Many Relationships Conventions
The easiest way to configure a one-to-many relationship is by convention. EF Core will create a relationship if an entity contains a navigation...
Read more >ef core one-to-one property is always null-entityframework core
Entity Framework Core Set null one property of entity · Navigation property is always null when using Include with EF Core · EF...
Read more >Empty instance instead of null returned for owned navigation ...
HasOne relationship (AnAggregateRoot.AnEntity) => owner is returning null for the navigation property (works as expected). OwnsOne relationship ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @jjtang1985, thanks for notifying about the fix. I’ve successfully tested with the canary version. Best regards, ja-ne
Hi @ja-ne , the PR #1141 has been merged and you’ll find it in the next stable release. Please note, the fix contains two parts:
@sap-cloud-sdk/core
, which contains the fix offromJson
for the runtime error. This might be released next week.@sap/cloud-sdk-vdm-*
, which contains the type-safe clients (type error at compile time). This might take a while for a new release.For the time being, you can already test the
canary
version of@sap-cloud-sdk/core
, which contains the fix. Please let know if it helps if possible.Best, Junjie