Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading default value from model for decision making #34634

Closed
rhariraman opened this issue Sep 9, 2024 · 1 comment
Closed

Reading default value from model for decision making #34634

rhariraman opened this issue Sep 9, 2024 · 1 comment
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported

Comments

@rhariraman
Copy link

rhariraman commented Sep 9, 2024

I saw the following issue has been fixed as part of EF core 9 version upgrade, hence thought of trying in my project.
#21006

After making the field as non-nullable and providing the default value, it worked while reading a particular document from the Azure Cosmos DB. However I was facing the issue while trying to read the specific attribute to make a decision.

For example,

I have a user model with the attributes like,

id
FirstName
LastName
...

I have decided to add a new attribute called

IsDeleted

I have kept this as non-nullable and provided the default as false in the model. This value isn't present for the existing documents.

With the EF core 9 upgrade, I am trying to read this user and I am able to see the user object is being populated with the value as false instead of null. But when I try to make a decision by checking the value of the attribute like below,

    user = user.IsDeleted == false ? user : null;

Here it fails with the following error. Could you help me how to resolve this?

     error CS0229: Ambiguity between 'UserModel.IsDeleted' and 'UserModel.IsDeleted' |  
@AndriySvyryd
Copy link
Member

That's just a compiler error. Review your code to make sure you only declared UserModel.IsDeleted once.

@AndriySvyryd AndriySvyryd closed this as not planned Won't fix, can't repro, duplicate, stale Sep 14, 2024
@AndriySvyryd AndriySvyryd added the closed-no-further-action The issue is closed and no further action is planned. label Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported
Projects
None yet
Development

No branches or pull requests

2 participants