@@ -203,12 +203,52 @@ public void Bind_GeneratedExpression_ContainsExpandedObject()
203
203
. ToDictionary ( PropertyMapper ) [ "Orders" ] as IEnumerable < SelectExpandWrapper < QueryOrder > > ;
204
204
Assert . NotNull ( innerOrders ) ;
205
205
SelectExpandWrapper < QueryOrder > partialOrder = innerOrders . Single ( ) ;
206
+ var tt = _queryable . First ( ) . Orders . First ( ) ;
207
+ var xx = _queryable . First ( ) ;
206
208
Assert . Same ( _queryable . First ( ) . Orders . First ( ) , partialOrder . Instance ) ;
207
209
object customer = partialOrder . Container . ToDictionary ( PropertyMapper ) [ "Customer" ] ;
208
210
SelectExpandWrapper < QueryCustomer > innerInnerCustomer = Assert . IsAssignableFrom < SelectExpandWrapper < QueryCustomer > > ( customer ) ;
209
211
Assert . Same ( _queryable . First ( ) , innerInnerCustomer . Instance ) ;
210
212
}
211
213
214
+ [ Theory ]
215
+ [ InlineData ( HandleNullPropagationOptionHelper . EntityFrameworkQueryProviderNamespace ) ]
216
+ [ InlineData ( HandleNullPropagationOptionHelper . ObjectContextQueryProviderNamespaceEFCore2 ) ]
217
+ [ InlineData ( HandleNullPropagationOptionHelper . ObjectContextQueryProviderNamespaceEF5 ) ]
218
+ [ InlineData ( HandleNullPropagationOptionHelper . ObjectContextQueryProviderNamespaceEF6 ) ]
219
+ public void Bind_UsingEFQueryProvider_GeneratedExpression_ContainsExpandedObject ( string queryProvider )
220
+ {
221
+ // Arrange
222
+ SelectExpandQueryOption selectExpand = new SelectExpandQueryOption ( "Orders" , "Orders,Orders($expand=Customer)" , _context ) ;
223
+
224
+ // Act
225
+ SelectExpandBinder binder = new SelectExpandBinder ( ) ;
226
+ _queryBinderContext . QueryProvider = queryProvider ;
227
+ IQueryable queryable = binder . ApplyBind ( _queryable , selectExpand . SelectExpandClause , _queryBinderContext ) ;
228
+
229
+ // Assert
230
+ IEnumerator enumerator = queryable . GetEnumerator ( ) ;
231
+ Assert . True ( enumerator . MoveNext ( ) ) ;
232
+ var partialCustomer = Assert . IsAssignableFrom < SelectExpandWrapper < QueryCustomer > > ( enumerator . Current ) ;
233
+ Assert . False ( enumerator . MoveNext ( ) ) ;
234
+ Assert . Null ( partialCustomer . Instance ) ;
235
+ Assert . Equal ( "Microsoft.AspNetCore.OData.Tests.Query.Expressions.QueryCustomer" , partialCustomer . InstanceType ) ;
236
+ IEnumerable < SelectExpandWrapper < QueryOrder > > innerOrders = partialCustomer . Container
237
+ . ToDictionary ( PropertyMapper ) [ "Orders" ] as IEnumerable < SelectExpandWrapper < QueryOrder > > ;
238
+ Assert . NotNull ( innerOrders ) ;
239
+ SelectExpandWrapper < QueryOrder > partialOrder = innerOrders . Single ( ) ;
240
+
241
+ // We only write structural properties to the instance.
242
+ // This means that navigation properties on the instance property will be null
243
+ // when using any instance of EF query provider.
244
+ Assert . Null ( partialOrder . Instance . Customer ) ;
245
+
246
+ object customer = partialOrder . Container . ToDictionary ( PropertyMapper ) [ "Customer" ] ;
247
+ SelectExpandWrapper < QueryCustomer > innerInnerCustomer = Assert . IsAssignableFrom < SelectExpandWrapper < QueryCustomer > > ( customer ) ;
248
+
249
+ Assert . Null ( innerInnerCustomer . Instance . Orders ) ;
250
+ }
251
+
212
252
[ Fact ]
213
253
public void Bind_GeneratedExpression_CheckNullObjectWithinChainProjectionByKey ( )
214
254
{
0 commit comments