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

Client 8.0.0 - Projection fails for navigation property being null #3037

Closed
uffelauesen opened this issue Aug 15, 2024 · 1 comment · Fixed by #3038
Closed

Client 8.0.0 - Projection fails for navigation property being null #3037

uffelauesen opened this issue Aug 15, 2024 · 1 comment · Fixed by #3038

Comments

@uffelauesen
Copy link
Contributor

Projection with a navigation property being null throws System.ArgumentNullException: Value cannot be null. (Parameter 'source')

Assemblies affected

This bug were introduced in ODL Client 8.0.0.rc.1 and is still present in ODL 8.0.0. ODL Client 8.0.0.preview.3 and earlier does not have this issue.

Reproduce steps

Imagine a model with a Person having a navigation property Spouse of type Person that can be null. Then the error can be reproduced with this code (provided that you have people without spouses in your store)...

            var q = from p in ctx.People
                    where p.Spouse == null
                    select new Person
                    {
                        ID = p.ID,
                        Spouse = p.Spouse
                    };

            var results = q.ToList();

Expected result

Results are materialized correctly having null as navigation property value.

Actual result

An exception is thrown when the response is materialized...

System.ArgumentNullException: Value cannot be null. (Parameter 'source')

ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)

ODataEntityMaterializer.ProjectionValueForPath(MaterializerEntry entry, Type expectedType, ProjectionPath path)
ODataEntityMaterializerInvoker.ProjectionValueForPath(Object materializer, Object entry, Type expectedType, Object path)
lambda_method3885(Closure, Object, Object, Type)
ODataEntityMaterializer.ProjectionInitializeEntity(ODataEntityMaterializer materializer, MaterializerEntry entry, Type expectedType, Type resultType, String[] properties, Func4[] propertyValues) lambda_method3886(Closure, Object, Object, Type) ProjectionPlan.Run(ODataEntityMaterializer materializer, ODataResource entry, Type expectedType) ODataEntityMaterializer.ReadImplementation() ObjectMaterializer.MoveNextInternal() ObjectMaterializer.MoveNext() Enumerable.CastIterator[TResult](IEnumerable source)+MoveNext() List1.ctor(IEnumerable1 collection) Enumerable.ToList[TSource](IEnumerable1 source)

Additional detail

@habbes
Copy link
Contributor

habbes commented Aug 15, 2024

Seems like the issue was introduced by this PR: #2916

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants