@@ -219,7 +219,7 @@ when entityQueryRootExpression.GetType() == typeof(EntityQueryRootExpression)
219
219
Check . DebugAssert ( sqlParameterExpression is not null , "sqlParameterExpression is not null" ) ;
220
220
return TranslateCollection (
221
221
sqlParameterExpression ,
222
- elementTypeMapping : null ,
222
+ property : null ,
223
223
char . ToLowerInvariant ( sqlParameterExpression . Name . First ( c => c != '_' ) ) . ToString ( ) )
224
224
?? base . VisitExtension ( extensionExpression ) ;
225
225
@@ -265,20 +265,22 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
265
265
if ( translated == QueryCompilationContext . NotTranslatedExpression )
266
266
{
267
267
// Attempt to translate access into a primitive collection property (i.e. array column)
268
- if ( _sqlTranslator . TryTranslatePropertyAccess ( methodCallExpression , out var propertyAccessExpression )
269
- && propertyAccessExpression is SqlExpression
270
- {
271
- TypeMapping . ElementTypeMapping : RelationalTypeMapping elementTypeMapping
272
- } collectionPropertyAccessExpression )
268
+ if ( _sqlTranslator . TryTranslatePropertyAccess ( methodCallExpression , out var translatedExpression , out var property )
269
+ && property is IProperty regularProperty
270
+ && regularProperty . GetElementType ( ) is not null )
273
271
{
274
- var tableAlias = collectionPropertyAccessExpression switch
272
+ Check . DebugAssert (
273
+ translatedExpression is SqlExpression { TypeMapping . ElementTypeMapping : not null } ,
274
+ "Translated property access for a primitive collection property isn't a SqlExpression with a type mapping" ) ;
275
+
276
+ var tableAlias = translatedExpression switch
275
277
{
276
278
ColumnExpression c => c . Name [ ..1 ] . ToLowerInvariant ( ) ,
277
279
JsonScalarExpression { Path : [ .., { PropertyName : string propertyName } ] } => propertyName [ ..1 ] . ToLowerInvariant ( ) ,
278
280
_ => "j"
279
281
} ;
280
282
281
- if ( TranslateCollection ( collectionPropertyAccessExpression , elementTypeMapping , tableAlias ) is
283
+ if ( TranslateCollection ( ( SqlExpression ) translatedExpression , regularProperty , tableAlias ) is
282
284
{ } primitiveCollectionTranslation )
283
285
{
284
286
return primitiveCollectionTranslation ;
@@ -316,17 +318,15 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
316
318
/// collections.
317
319
/// </remarks>
318
320
/// <param name="sqlExpression">The expression to try to translate as a primitive collection expression.</param>
319
- /// <param name="elementTypeMapping">
320
- /// The type mapping of the collection's element, or <see langword="null" /> when it's not known (i.e. for parameters).
321
+ /// <param name="property">
322
+ /// If the primitive collection is a property, contains the <see cref="IProperty" /> for that property. Otherwise, the collection
323
+ /// represents a parameter, and this contains <see langword="null" />.
321
324
/// </param>
322
325
/// <param name="tableAlias">
323
326
/// Provides an alias to be used for the table returned from translation, which will represent the collection.
324
327
/// </param>
325
328
/// <returns>A <see cref="ShapedQueryExpression" /> if the translation was successful, otherwise <see langword="null" />.</returns>
326
- protected virtual ShapedQueryExpression ? TranslateCollection (
327
- SqlExpression sqlExpression ,
328
- RelationalTypeMapping ? elementTypeMapping ,
329
- string tableAlias )
329
+ protected virtual ShapedQueryExpression ? TranslateCollection ( SqlExpression sqlExpression , IProperty ? property , string tableAlias )
330
330
=> null ;
331
331
332
332
/// <summary>
0 commit comments