-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Materialization condition for optional dependents with all null properties but having own optional dependent #21488
Comments
An optional dependent considered present If all non-nullable non-PK properties have a non-null value, or If all non-nullable non-PK properties are shared with principal then at least one nullable non shared property has a non-null value If there are no non-shared properties then it is always present and act like a required dependent Resolves #23564 Resolves #21488 Resolves #23198
An optional dependent considered present If all non-nullable non-PK properties have a non-null value, or If all non-nullable non-PK properties are shared with principal then at least one nullable non shared property has a non-null value If there are no non-shared properties then it is always present and act like a required dependent Resolves #23564 Resolves #21488 Resolves #23198
We decided that we are going to throw for this scenario and user must add a required property in the middle dependent which can serve as identifying property to determine materialization. |
Just looking for a little more detail. Does this mean that if this situation occurs, an exception will be thrown rather than not returning the data expected? To add a required property as suggested, can you change the Operator class and add the property Ignore, like this? [Table("Vehicles")]
public class Operator
{
public int Id { get; set; }
public string OperatorName { get; set; }
[ForeignKey("Id")]
public Vehicle Vehicle { get; set; }
public OperatorDetails OperatorDetails { get; set; }
public int Ignore { get; private set; } = 0;
} |
Using 5.0 preview6
Repro code:
We generate following SQL,
Issue: Vehicle -> Operator -> OperatorDetails are sharing table here. All the non-pk properties of Operator are nullable.
While generating SQL we generate Union with the dependents (to include operators which have associated OperatorDetails) regardless of values in Operator columns. But when we are materializing we don't have that information. We only have ValueBuffer associated with Operator and which has PK with non-null value and rest is null values. PK is expected to non-null due to table splitting. Hence we don't materialize the instance and above throws null ref.
The text was updated successfully, but these errors were encountered: