diff --git a/src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs b/src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs
index 01d72c30352..62fd37c9950 100644
--- a/src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs
+++ b/src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs
@@ -110,6 +110,8 @@ protected virtual void ValidateSharedContainerCompatibility(
int? defaultTtl = null;
ThroughputProperties? throughput = null;
IEntityType? firstEntityType = null;
+ bool? isDiscriminatorMappingComplete = null;
+
foreach (var entityType in mappedTypes)
{
Check.DebugAssert(entityType.IsDocumentRoot(), "Only document roots expected here.");
@@ -177,6 +179,19 @@ protected virtual void ValidateSharedContainerCompatibility(
}
discriminatorValues[discriminatorValue] = entityType;
+
+ var currentIsDiscriminatorMappingComplete = entityType.GetIsDiscriminatorMappingComplete();
+ if (isDiscriminatorMappingComplete == null)
+ {
+ isDiscriminatorMappingComplete = currentIsDiscriminatorMappingComplete;
+ }
+ else if (currentIsDiscriminatorMappingComplete != isDiscriminatorMappingComplete)
+ {
+ throw new InvalidOperationException(
+ CosmosStrings.IsDiscriminatorMappingCompleteMismatch(
+ isDiscriminatorMappingComplete, firstEntityType.DisplayName(), entityType.DisplayName(),
+ currentIsDiscriminatorMappingComplete, container));
+ }
}
var currentAnalyticalTtl = entityType.GetAnalyticalStoreTimeToLive();
diff --git a/src/EFCore.Cosmos/Properties/CosmosStrings.Designer.cs b/src/EFCore.Cosmos/Properties/CosmosStrings.Designer.cs
index d96dac77c0d..4402ce74916 100644
--- a/src/EFCore.Cosmos/Properties/CosmosStrings.Designer.cs
+++ b/src/EFCore.Cosmos/Properties/CosmosStrings.Designer.cs
@@ -137,6 +137,14 @@ public static string InvalidFromSqlArguments(object? expressionType, object? val
public static string InvalidResourceId
=> GetString("InvalidResourceId");
+ ///
+ /// The IsDiscriminatorMappingComplete setting was configured to '{isDiscriminatorMappingComplete1}' on '{entityType1}', but on '{entityType2}' it was configured to '{isDiscriminatorMappingComplete2}'. All entity types mapped to the same container '{container}' must be configured with the same IsDiscriminatorMappingComplete value.
+ ///
+ public static string IsDiscriminatorMappingCompleteMismatch(object? isDiscriminatorMappingComplete1, object? entityType1, object? entityType2, object? isDiscriminatorMappingComplete2, object? container)
+ => string.Format(
+ GetString("IsDiscriminatorMappingCompleteMismatch", nameof(isDiscriminatorMappingComplete1), nameof(entityType1), nameof(entityType2), nameof(isDiscriminatorMappingComplete2), nameof(container)),
+ isDiscriminatorMappingComplete1, entityType1, entityType2, isDiscriminatorMappingComplete2, container);
+
///
/// Both properties '{property1}' and '{property2}' on entity type '{entityType}' are mapped to '{storeName}'. Map one of the properties to a different JSON property.
///
diff --git a/src/EFCore.Cosmos/Properties/CosmosStrings.resx b/src/EFCore.Cosmos/Properties/CosmosStrings.resx
index f6304c2fb50..34887367904 100644
--- a/src/EFCore.Cosmos/Properties/CosmosStrings.resx
+++ b/src/EFCore.Cosmos/Properties/CosmosStrings.resx
@@ -165,6 +165,9 @@
Unable to generate a valid 'id' value to execute a 'ReadItem' query. This usually happens when the value provided for one of the properties is 'null' or an empty string. Please supply a value that's not 'null' or an empty string.
+
+ The IsDiscriminatorMappingComplete setting was configured to '{isDiscriminatorMappingComplete1}' on '{entityType1}', but on '{entityType2}' it was configured to '{isDiscriminatorMappingComplete2}'. All entity types mapped to the same container '{container}' must be configured with the same IsDiscriminatorMappingComplete value.
+
Both properties '{property1}' and '{property2}' on entity type '{entityType}' are mapped to '{storeName}'. Map one of the properties to a different JSON property.
diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitor.cs
index 2addf5a33e9..d128a9182f5 100644
--- a/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitor.cs
+++ b/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitor.cs
@@ -234,6 +234,7 @@ public override Expression Translate(Expression expression)
(property, parameter) => (property, parameter))
.ToDictionary(tuple => tuple.property, tuple => tuple.parameter);
+ // TODO: Reimplement ReadItem properly: #34157
_readItemInfo = new ReadItemInfo(entityType, propertyParameterList, clrType);
}
}
@@ -427,38 +428,34 @@ protected override ShapedQueryExpression CreateShapedQueryExpression(IEntityType
// Add discriminator predicate
var concreteEntityTypes = entityType.GetConcreteDerivedTypesInclusive().ToList();
- if (concreteEntityTypes.Count == 1)
+ if (concreteEntityTypes is [var singleEntityType]
+ && singleEntityType.GetIsDiscriminatorMappingComplete()
+ && entityType.GetContainer() is var container
+ && !entityType.Model.GetEntityTypes().Any(e => e.GetContainer() == container && e != singleEntityType))
{
- var concreteEntityType = concreteEntityTypes[0];
- var discriminatorProperty = concreteEntityType.FindDiscriminatorProperty();
- if (discriminatorProperty != null)
+ // There's a single entity type mapped to the container and the discriminator mapping is complete; we can skip the
+ // discriminator predicate.
+ }
+ else
+ {
+ var discriminatorProperty = concreteEntityTypes[0].FindDiscriminatorProperty();
+ Check.DebugAssert(
+ discriminatorProperty is not null || concreteEntityTypes.Count == 1,
+ "Missing discriminator property in hierarchy");
+ if (discriminatorProperty is not null)
{
var discriminatorColumn = ((EntityProjectionExpression)selectExpression.GetMappedProjection(new ProjectionMember()))
.BindProperty(discriminatorProperty, clientEval: false);
var success = TryApplyPredicate(
selectExpression,
- _sqlExpressionFactory.Equal(
+ _sqlExpressionFactory.In(
(SqlExpression)discriminatorColumn,
- _sqlExpressionFactory.Constant(concreteEntityType.GetDiscriminatorValue(), discriminatorColumn.Type)));
+ concreteEntityTypes.Select(et => _sqlExpressionFactory.Constant(et.GetDiscriminatorValue(), discriminatorColumn.Type))
+ .ToArray()));
Check.DebugAssert(success, "Couldn't apply predicate when creating a new ShapedQueryExpression");
}
}
- else
- {
- var discriminatorProperty = concreteEntityTypes[0].FindDiscriminatorProperty();
- Check.DebugAssert(discriminatorProperty is not null, "Missing discriminator property in hierarchy");
- var discriminatorColumn = ((EntityProjectionExpression)selectExpression.GetMappedProjection(new ProjectionMember()))
- .BindProperty(discriminatorProperty, clientEval: false);
-
- var success = TryApplyPredicate(
- selectExpression,
- _sqlExpressionFactory.In(
- (SqlExpression)discriminatorColumn,
- concreteEntityTypes.Select(et => _sqlExpressionFactory.Constant(et.GetDiscriminatorValue(), discriminatorColumn.Type))
- .ToArray()));
- Check.DebugAssert(success, "Couldn't apply predicate when creating a new ShapedQueryExpression");
- }
return CreateShapedQueryExpression(entityType, selectExpression);
}
@@ -834,7 +831,7 @@ protected override ShapedQueryExpression TranslateCast(ShapedQueryExpression sou
return null;
}
- if (select is { Predicate: null, Orderings: [] })
+ if (select is { Orderings: [], Predicate: null, ReadItemInfo: null })
{
_queryCompilationContext.Logger.FirstWithoutOrderByAndFilterWarning();
}
diff --git a/src/EFCore.Cosmos/Query/Internal/Expressions/SelectExpression.cs b/src/EFCore.Cosmos/Query/Internal/Expressions/SelectExpression.cs
index 5e7b9ecf8ce..3eea7d26e9e 100644
--- a/src/EFCore.Cosmos/Query/Internal/Expressions/SelectExpression.cs
+++ b/src/EFCore.Cosmos/Query/Internal/Expressions/SelectExpression.cs
@@ -29,6 +29,7 @@ public sealed class SelectExpression : Expression, IPrintableExpression
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
+ // TODO: Reimplement ReadItem properly: #34157
public ReadItemInfo? ReadItemInfo { get; init; }
///
diff --git a/src/EFCore.Cosmos/Query/Internal/ISqlExpressionFactory.cs b/src/EFCore.Cosmos/Query/Internal/ISqlExpressionFactory.cs
index 38f48db70ee..b1abb161f11 100644
--- a/src/EFCore.Cosmos/Query/Internal/ISqlExpressionFactory.cs
+++ b/src/EFCore.Cosmos/Query/Internal/ISqlExpressionFactory.cs
@@ -45,11 +45,7 @@ public interface ISqlExpressionFactory
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlBinaryExpression? MakeBinary(
- ExpressionType operatorType,
- SqlExpression left,
- SqlExpression right,
- CoreTypeMapping? typeMapping);
+ SqlExpression? MakeBinary(ExpressionType operatorType, SqlExpression left, SqlExpression right, CoreTypeMapping? typeMapping);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -57,7 +53,7 @@ public interface ISqlExpressionFactory
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlBinaryExpression Equal(SqlExpression left, SqlExpression right);
+ SqlExpression Equal(SqlExpression left, SqlExpression right);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -65,14 +61,14 @@ public interface ISqlExpressionFactory
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlBinaryExpression NotEqual(SqlExpression left, SqlExpression right);
+ SqlExpression NotEqual(SqlExpression left, SqlExpression right);
///
/// Creates a new which represents an EXISTS operation in a SQL tree.
///
/// A subquery to check existence of.
/// An expression representing an EXISTS operation in a SQL tree.
- ExistsExpression Exists(SelectExpression subquery);
+ SqlExpression Exists(SelectExpression subquery);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -80,7 +76,7 @@ public interface ISqlExpressionFactory
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlBinaryExpression GreaterThan(SqlExpression left, SqlExpression right);
+ SqlExpression GreaterThan(SqlExpression left, SqlExpression right);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -88,7 +84,7 @@ public interface ISqlExpressionFactory
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlBinaryExpression GreaterThanOrEqual(SqlExpression left, SqlExpression right);
+ SqlExpression GreaterThanOrEqual(SqlExpression left, SqlExpression right);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -96,7 +92,7 @@ public interface ISqlExpressionFactory
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlBinaryExpression LessThan(SqlExpression left, SqlExpression right);
+ SqlExpression LessThan(SqlExpression left, SqlExpression right);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -104,7 +100,7 @@ public interface ISqlExpressionFactory
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlBinaryExpression LessThanOrEqual(SqlExpression left, SqlExpression right);
+ SqlExpression LessThanOrEqual(SqlExpression left, SqlExpression right);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -112,7 +108,7 @@ public interface ISqlExpressionFactory
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlBinaryExpression AndAlso(SqlExpression left, SqlExpression right);
+ SqlExpression AndAlso(SqlExpression left, SqlExpression right);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -120,7 +116,7 @@ public interface ISqlExpressionFactory
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlBinaryExpression OrElse(SqlExpression left, SqlExpression right);
+ SqlExpression OrElse(SqlExpression left, SqlExpression right);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -128,10 +124,7 @@ public interface ISqlExpressionFactory
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlBinaryExpression Add(
- SqlExpression left,
- SqlExpression right,
- CoreTypeMapping? typeMapping = null);
+ SqlExpression Add(SqlExpression left, SqlExpression right, CoreTypeMapping? typeMapping = null);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -139,10 +132,7 @@ SqlBinaryExpression Add(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlBinaryExpression Subtract(
- SqlExpression left,
- SqlExpression right,
- CoreTypeMapping? typeMapping = null);
+ SqlExpression Subtract(SqlExpression left, SqlExpression right, CoreTypeMapping? typeMapping = null);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -150,10 +140,7 @@ SqlBinaryExpression Subtract(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlBinaryExpression Multiply(
- SqlExpression left,
- SqlExpression right,
- CoreTypeMapping? typeMapping = null);
+ SqlExpression Multiply(SqlExpression left, SqlExpression right, CoreTypeMapping? typeMapping = null);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -161,10 +148,7 @@ SqlBinaryExpression Multiply(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlBinaryExpression Divide(
- SqlExpression left,
- SqlExpression right,
- CoreTypeMapping? typeMapping = null);
+ SqlExpression Divide(SqlExpression left, SqlExpression right, CoreTypeMapping? typeMapping = null);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -172,10 +156,7 @@ SqlBinaryExpression Divide(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlBinaryExpression Modulo(
- SqlExpression left,
- SqlExpression right,
- CoreTypeMapping? typeMapping = null);
+ SqlExpression Modulo(SqlExpression left, SqlExpression right, CoreTypeMapping? typeMapping = null);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -183,10 +164,7 @@ SqlBinaryExpression Modulo(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlBinaryExpression And(
- SqlExpression left,
- SqlExpression right,
- CoreTypeMapping? typeMapping = null);
+ SqlExpression And(SqlExpression left, SqlExpression right, CoreTypeMapping? typeMapping = null);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -194,10 +172,7 @@ SqlBinaryExpression And(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlBinaryExpression Or(
- SqlExpression left,
- SqlExpression right,
- CoreTypeMapping? typeMapping = null);
+ SqlExpression Or(SqlExpression left, SqlExpression right, CoreTypeMapping? typeMapping = null);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -213,7 +188,7 @@ SqlBinaryExpression Or(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlBinaryExpression IsNull(SqlExpression operand);
+ SqlExpression IsNull(SqlExpression operand);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -221,7 +196,7 @@ SqlBinaryExpression Or(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlBinaryExpression IsNotNull(SqlExpression operand);
+ SqlExpression IsNotNull(SqlExpression operand);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -229,7 +204,7 @@ SqlBinaryExpression Or(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlBinaryExpression ArrayIndex(SqlExpression left, SqlExpression right, Type type, CoreTypeMapping? typeMapping = null);
+ SqlExpression ArrayIndex(SqlExpression left, SqlExpression right, Type type, CoreTypeMapping? typeMapping = null);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -237,10 +212,7 @@ SqlBinaryExpression Or(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlUnaryExpression Convert(
- SqlExpression operand,
- Type type,
- CoreTypeMapping? typeMapping = null);
+ SqlExpression Convert(SqlExpression operand, Type type, CoreTypeMapping? typeMapping = null);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -248,7 +220,7 @@ SqlUnaryExpression Convert(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlUnaryExpression Not(SqlExpression operand);
+ SqlExpression Not(SqlExpression operand);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -256,7 +228,7 @@ SqlUnaryExpression Convert(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlUnaryExpression Negate(SqlExpression operand);
+ SqlExpression Negate(SqlExpression operand);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -264,11 +236,7 @@ SqlUnaryExpression Convert(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlFunctionExpression Function(
- string functionName,
- IEnumerable arguments,
- Type returnType,
- CoreTypeMapping? typeMapping = null);
+ SqlExpression Function(string functionName, IEnumerable arguments, Type returnType, CoreTypeMapping? typeMapping = null);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -276,10 +244,7 @@ SqlFunctionExpression Function(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- SqlConditionalExpression Condition(
- SqlExpression test,
- SqlExpression ifTrue,
- SqlExpression ifFalse);
+ SqlExpression Condition(SqlExpression test, SqlExpression ifTrue, SqlExpression ifFalse);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -287,7 +252,7 @@ SqlConditionalExpression Condition(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- InExpression In(SqlExpression item, SqlParameterExpression valuesParameter);
+ SqlExpression In(SqlExpression item, SqlParameterExpression valuesParameter);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -295,7 +260,7 @@ SqlConditionalExpression Condition(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- InExpression In(SqlExpression item, IReadOnlyList values);
+ SqlExpression In(SqlExpression item, IReadOnlyList values);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Cosmos/Query/Internal/SqlExpressionFactory.cs b/src/EFCore.Cosmos/Query/Internal/SqlExpressionFactory.cs
index 477bc520043..ba466916174 100644
--- a/src/EFCore.Cosmos/Query/Internal/SqlExpressionFactory.cs
+++ b/src/EFCore.Cosmos/Query/Internal/SqlExpressionFactory.cs
@@ -315,7 +315,7 @@ var t when t.TryGetSequenceType() != typeof(object) => t,
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlBinaryExpression? MakeBinary(
+ public virtual SqlExpression? MakeBinary(
ExpressionType operatorType,
SqlExpression left,
SqlExpression right,
@@ -351,7 +351,7 @@ var t when t.TryGetSequenceType() != typeof(object) => t,
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlBinaryExpression Equal(SqlExpression left, SqlExpression right)
+ public virtual SqlExpression Equal(SqlExpression left, SqlExpression right)
=> MakeBinary(ExpressionType.Equal, left, right, null)!;
///
@@ -360,7 +360,7 @@ public virtual SqlBinaryExpression Equal(SqlExpression left, SqlExpression right
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlBinaryExpression NotEqual(SqlExpression left, SqlExpression right)
+ public virtual SqlExpression NotEqual(SqlExpression left, SqlExpression right)
=> MakeBinary(ExpressionType.NotEqual, left, right, null)!;
///
@@ -369,8 +369,8 @@ public virtual SqlBinaryExpression NotEqual(SqlExpression left, SqlExpression ri
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual ExistsExpression Exists(SelectExpression subquery)
- => new(subquery, _boolTypeMapping);
+ public virtual SqlExpression Exists(SelectExpression subquery)
+ => new ExistsExpression(subquery, _boolTypeMapping);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -378,7 +378,7 @@ public virtual ExistsExpression Exists(SelectExpression subquery)
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlBinaryExpression GreaterThan(SqlExpression left, SqlExpression right)
+ public virtual SqlExpression GreaterThan(SqlExpression left, SqlExpression right)
=> MakeBinary(ExpressionType.GreaterThan, left, right, null)!;
///
@@ -387,7 +387,7 @@ public virtual SqlBinaryExpression GreaterThan(SqlExpression left, SqlExpression
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlBinaryExpression GreaterThanOrEqual(SqlExpression left, SqlExpression right)
+ public virtual SqlExpression GreaterThanOrEqual(SqlExpression left, SqlExpression right)
=> MakeBinary(ExpressionType.GreaterThanOrEqual, left, right, null)!;
///
@@ -396,7 +396,7 @@ public virtual SqlBinaryExpression GreaterThanOrEqual(SqlExpression left, SqlExp
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlBinaryExpression LessThan(SqlExpression left, SqlExpression right)
+ public virtual SqlExpression LessThan(SqlExpression left, SqlExpression right)
=> MakeBinary(ExpressionType.LessThan, left, right, null)!;
///
@@ -405,7 +405,7 @@ public virtual SqlBinaryExpression LessThan(SqlExpression left, SqlExpression ri
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlBinaryExpression LessThanOrEqual(SqlExpression left, SqlExpression right)
+ public virtual SqlExpression LessThanOrEqual(SqlExpression left, SqlExpression right)
=> MakeBinary(ExpressionType.LessThanOrEqual, left, right, null)!;
///
@@ -414,7 +414,7 @@ public virtual SqlBinaryExpression LessThanOrEqual(SqlExpression left, SqlExpres
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlBinaryExpression AndAlso(SqlExpression left, SqlExpression right)
+ public virtual SqlExpression AndAlso(SqlExpression left, SqlExpression right)
=> MakeBinary(ExpressionType.AndAlso, left, right, null)!;
///
@@ -423,7 +423,7 @@ public virtual SqlBinaryExpression AndAlso(SqlExpression left, SqlExpression rig
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlBinaryExpression OrElse(SqlExpression left, SqlExpression right)
+ public virtual SqlExpression OrElse(SqlExpression left, SqlExpression right)
=> MakeBinary(ExpressionType.OrElse, left, right, null)!;
///
@@ -432,7 +432,7 @@ public virtual SqlBinaryExpression OrElse(SqlExpression left, SqlExpression righ
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlBinaryExpression Add(SqlExpression left, SqlExpression right, CoreTypeMapping? typeMapping = null)
+ public virtual SqlExpression Add(SqlExpression left, SqlExpression right, CoreTypeMapping? typeMapping = null)
=> MakeBinary(ExpressionType.Add, left, right, typeMapping)!;
///
@@ -441,7 +441,7 @@ public virtual SqlBinaryExpression Add(SqlExpression left, SqlExpression right,
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlBinaryExpression Subtract(SqlExpression left, SqlExpression right, CoreTypeMapping? typeMapping = null)
+ public virtual SqlExpression Subtract(SqlExpression left, SqlExpression right, CoreTypeMapping? typeMapping = null)
=> MakeBinary(ExpressionType.Subtract, left, right, typeMapping)!;
///
@@ -450,7 +450,7 @@ public virtual SqlBinaryExpression Subtract(SqlExpression left, SqlExpression ri
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlBinaryExpression Multiply(SqlExpression left, SqlExpression right, CoreTypeMapping? typeMapping = null)
+ public virtual SqlExpression Multiply(SqlExpression left, SqlExpression right, CoreTypeMapping? typeMapping = null)
=> MakeBinary(ExpressionType.Multiply, left, right, typeMapping)!;
///
@@ -459,7 +459,7 @@ public virtual SqlBinaryExpression Multiply(SqlExpression left, SqlExpression ri
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlBinaryExpression Divide(SqlExpression left, SqlExpression right, CoreTypeMapping? typeMapping = null)
+ public virtual SqlExpression Divide(SqlExpression left, SqlExpression right, CoreTypeMapping? typeMapping = null)
=> MakeBinary(ExpressionType.Divide, left, right, typeMapping)!;
///
@@ -468,7 +468,7 @@ public virtual SqlBinaryExpression Divide(SqlExpression left, SqlExpression righ
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlBinaryExpression Modulo(SqlExpression left, SqlExpression right, CoreTypeMapping? typeMapping = null)
+ public virtual SqlExpression Modulo(SqlExpression left, SqlExpression right, CoreTypeMapping? typeMapping = null)
=> MakeBinary(ExpressionType.Modulo, left, right, typeMapping)!;
///
@@ -477,7 +477,7 @@ public virtual SqlBinaryExpression Modulo(SqlExpression left, SqlExpression righ
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlBinaryExpression And(SqlExpression left, SqlExpression right, CoreTypeMapping? typeMapping = null)
+ public virtual SqlExpression And(SqlExpression left, SqlExpression right, CoreTypeMapping? typeMapping = null)
=> MakeBinary(ExpressionType.And, left, right, typeMapping)!;
///
@@ -486,7 +486,7 @@ public virtual SqlBinaryExpression And(SqlExpression left, SqlExpression right,
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlBinaryExpression Or(SqlExpression left, SqlExpression right, CoreTypeMapping? typeMapping = null)
+ public virtual SqlExpression Or(SqlExpression left, SqlExpression right, CoreTypeMapping? typeMapping = null)
=> MakeBinary(ExpressionType.Or, left, right, typeMapping)!;
private SqlUnaryExpression? MakeUnary(
@@ -513,7 +513,7 @@ public virtual SqlExpression CoalesceUndefined(SqlExpression left, SqlExpression
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlBinaryExpression IsNull(SqlExpression operand)
+ public virtual SqlExpression IsNull(SqlExpression operand)
=> Equal(operand, Constant(null, operand.Type));
///
@@ -522,7 +522,7 @@ public virtual SqlBinaryExpression IsNull(SqlExpression operand)
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlBinaryExpression IsNotNull(SqlExpression operand)
+ public virtual SqlExpression IsNotNull(SqlExpression operand)
=> NotEqual(operand, Constant(null, operand.Type));
///
@@ -531,8 +531,8 @@ public virtual SqlBinaryExpression IsNotNull(SqlExpression operand)
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlBinaryExpression ArrayIndex(SqlExpression left, SqlExpression right, Type type, CoreTypeMapping? typeMapping = null)
- => new(ExpressionType.ArrayIndex, left, right, type, typeMapping)!;
+ public virtual SqlExpression ArrayIndex(SqlExpression left, SqlExpression right, Type type, CoreTypeMapping? typeMapping = null)
+ => new SqlBinaryExpression(ExpressionType.ArrayIndex, left, right, type, typeMapping)!;
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -540,7 +540,7 @@ public virtual SqlBinaryExpression ArrayIndex(SqlExpression left, SqlExpression
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlUnaryExpression Convert(SqlExpression operand, Type type, CoreTypeMapping? typeMapping = null)
+ public virtual SqlExpression Convert(SqlExpression operand, Type type, CoreTypeMapping? typeMapping = null)
=> MakeUnary(ExpressionType.Convert, operand, type, typeMapping)!;
///
@@ -549,7 +549,7 @@ public virtual SqlUnaryExpression Convert(SqlExpression operand, Type type, Core
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlUnaryExpression Not(SqlExpression operand)
+ public virtual SqlExpression Not(SqlExpression operand)
=> MakeUnary(ExpressionType.Not, operand, operand.Type, operand.TypeMapping)!;
///
@@ -558,7 +558,7 @@ public virtual SqlUnaryExpression Not(SqlExpression operand)
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlUnaryExpression Negate(SqlExpression operand)
+ public virtual SqlExpression Negate(SqlExpression operand)
=> MakeUnary(ExpressionType.Negate, operand, operand.Type, operand.TypeMapping)!;
///
@@ -567,7 +567,7 @@ public virtual SqlUnaryExpression Negate(SqlExpression operand)
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlFunctionExpression Function(
+ public virtual SqlExpression Function(
string functionName,
IEnumerable arguments,
Type returnType,
@@ -593,7 +593,7 @@ public virtual SqlFunctionExpression Function(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual SqlConditionalExpression Condition(SqlExpression test, SqlExpression ifTrue, SqlExpression ifFalse)
+ public virtual SqlExpression Condition(SqlExpression test, SqlExpression ifTrue, SqlExpression ifFalse)
{
var typeMapping = ExpressionExtensions.InferTypeMapping(ifTrue, ifFalse);
@@ -609,8 +609,10 @@ public virtual SqlConditionalExpression Condition(SqlExpression test, SqlExpress
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual InExpression In(SqlExpression item, IReadOnlyList values)
- => ApplyTypeMappingOnIn(new InExpression(item, values, _boolTypeMapping));
+ public virtual SqlExpression In(SqlExpression item, IReadOnlyList values)
+ => values is [var singleValue]
+ ? Equal(item, singleValue)
+ : ApplyTypeMappingOnIn(new InExpression(item, values, _boolTypeMapping));
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -618,7 +620,7 @@ public virtual InExpression In(SqlExpression item, IReadOnlyList
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual InExpression In(SqlExpression item, SqlParameterExpression valuesParameter)
+ public virtual SqlExpression In(SqlExpression item, SqlParameterExpression valuesParameter)
=> ApplyTypeMappingOnIn(new InExpression(item, valuesParameter, _boolTypeMapping));
///
diff --git a/src/EFCore.Cosmos/Query/Internal/Translators/CosmosDateTimeMemberTranslator.cs b/src/EFCore.Cosmos/Query/Internal/Translators/CosmosDateTimeMemberTranslator.cs
index 8a460c8547c..7ab28e58fcd 100644
--- a/src/EFCore.Cosmos/Query/Internal/Translators/CosmosDateTimeMemberTranslator.cs
+++ b/src/EFCore.Cosmos/Query/Internal/Translators/CosmosDateTimeMemberTranslator.cs
@@ -52,7 +52,7 @@ public class CosmosDateTimeMemberTranslator(ISqlExpressionFactory sqlExpressionF
_ => null
};
- SqlFunctionExpression DatePart(string part)
+ SqlExpression DatePart(string part)
=> sqlExpressionFactory.Function("DateTimePart", arguments: [sqlExpressionFactory.Constant(part), instance!], returnType);
}
}
diff --git a/src/EFCore.Relational/Query/ISqlExpressionFactory.cs b/src/EFCore.Relational/Query/ISqlExpressionFactory.cs
index 845258dfb80..0bc538aaa1d 100644
--- a/src/EFCore.Relational/Query/ISqlExpressionFactory.cs
+++ b/src/EFCore.Relational/Query/ISqlExpressionFactory.cs
@@ -142,10 +142,7 @@ public interface ISqlExpressionFactory
/// The right operand.
/// A type mapping to be assigned to the created expression.
/// An expression representing a SQL addition.
- SqlExpression Add(
- SqlExpression left,
- SqlExpression right,
- RelationalTypeMapping? typeMapping = null);
+ SqlExpression Add(SqlExpression left, SqlExpression right, RelationalTypeMapping? typeMapping = null);
///
/// Creates a which represents a subtraction.
@@ -154,10 +151,7 @@ SqlExpression Add(
/// The right operand.
/// A type mapping to be assigned to the created expression.
/// An expression representing a SQL subtraction.
- SqlExpression Subtract(
- SqlExpression left,
- SqlExpression right,
- RelationalTypeMapping? typeMapping = null);
+ SqlExpression Subtract(SqlExpression left, SqlExpression right, RelationalTypeMapping? typeMapping = null);
///
/// Creates a which represents a multiplication.
@@ -166,10 +160,7 @@ SqlExpression Subtract(
/// The right operand.
/// A type mapping to be assigned to the created expression.
/// An expression representing a SQL multiplication.
- SqlExpression Multiply(
- SqlExpression left,
- SqlExpression right,
- RelationalTypeMapping? typeMapping = null);
+ SqlExpression Multiply(SqlExpression left, SqlExpression right, RelationalTypeMapping? typeMapping = null);
///
/// Creates a which represents a division.
@@ -178,10 +169,7 @@ SqlExpression Multiply(
/// The right operand.
/// A type mapping to be assigned to the created expression.
/// An expression representing a SQL division.
- SqlExpression Divide(
- SqlExpression left,
- SqlExpression right,
- RelationalTypeMapping? typeMapping = null);
+ SqlExpression Divide(SqlExpression left, SqlExpression right, RelationalTypeMapping? typeMapping = null);
///
/// Creates a which represents a modulo operation.
@@ -190,10 +178,7 @@ SqlExpression Divide(
/// The right operand.
/// A type mapping to be assigned to the created expression.
/// An expression representing a SQL modulo operation.
- SqlExpression Modulo(
- SqlExpression left,
- SqlExpression right,
- RelationalTypeMapping? typeMapping = null);
+ SqlExpression Modulo(SqlExpression left, SqlExpression right, RelationalTypeMapping? typeMapping = null);
// Bitwise
///
@@ -203,10 +188,7 @@ SqlExpression Modulo(
/// The right operand.
/// A type mapping to be assigned to the created expression.
/// An expression representing a SQL bitwise AND operation.
- SqlExpression And(
- SqlExpression left,
- SqlExpression right,
- RelationalTypeMapping? typeMapping = null);
+ SqlExpression And(SqlExpression left, SqlExpression right, RelationalTypeMapping? typeMapping = null);
///
/// Creates a which represents a bitwise OR operation.
@@ -215,10 +197,7 @@ SqlExpression And(
/// The right operand.
/// A type mapping to be assigned to the created expression.
/// An expression representing a SQL bitwise OR operation.
- SqlExpression Or(
- SqlExpression left,
- SqlExpression right,
- RelationalTypeMapping? typeMapping = null);
+ SqlExpression Or(SqlExpression left, SqlExpression right, RelationalTypeMapping? typeMapping = null);
// Other
///
@@ -228,10 +207,7 @@ SqlExpression Or(
/// The right operand.
/// A type mapping to be assigned to the created expression.
/// An expression representing a SQL COALESCE operation.
- SqlExpression Coalesce(
- SqlExpression left,
- SqlExpression right,
- RelationalTypeMapping? typeMapping = null);
+ SqlExpression Coalesce(SqlExpression left, SqlExpression right, RelationalTypeMapping? typeMapping = null);
///
/// Creates a new which represent equality to null.
@@ -254,10 +230,7 @@ SqlExpression Coalesce(
/// The return type of the expression after cast.
/// A relational type mapping to use for conversion.
/// An expression representing cast operation in a SQL tree.
- SqlExpression Convert(
- SqlExpression operand,
- Type type,
- RelationalTypeMapping? typeMapping = null);
+ SqlExpression Convert(SqlExpression operand, Type type, RelationalTypeMapping? typeMapping = null);
///
/// Creates a new which represent a NOT operation in a SQL tree.
@@ -280,10 +253,7 @@ SqlExpression Convert(
/// A list of to compare or evaluate and get result from.
/// A value to return if no matches, if any.
/// An expression representing a CASE statement in a SQL tree.
- SqlExpression Case(
- SqlExpression? operand,
- IReadOnlyList whenClauses,
- SqlExpression? elseResult);
+ SqlExpression Case(SqlExpression? operand, IReadOnlyList whenClauses, SqlExpression? elseResult);
///
/// Creates a new which represent a CASE statement in a SQL tree.
diff --git a/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.CreateSelect.cs b/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.CreateSelect.cs
index 1bc5f19386e..bf3117141e9 100644
--- a/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.CreateSelect.cs
+++ b/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.CreateSelect.cs
@@ -429,15 +429,11 @@ private void AddEntitySelectConditions(SelectExpression selectExpression, IEntit
{
var discriminatorColumn = GetMappedProjection(selectExpression).BindProperty(discriminatorProperty);
var concreteEntityTypes = entityType.GetConcreteDerivedTypesInclusive().ToList();
- var predicate = concreteEntityTypes.Count == 1
- ? (SqlExpression)_sqlExpressionFactory.Equal(
- discriminatorColumn,
- _sqlExpressionFactory.Constant(concreteEntityTypes[0].GetDiscriminatorValue(), discriminatorColumn.Type))
- : _sqlExpressionFactory.In(
- discriminatorColumn,
- concreteEntityTypes
- .Select(et => _sqlExpressionFactory.Constant(et.GetDiscriminatorValue(), discriminatorColumn.Type))
- .ToArray());
+ var predicate = _sqlExpressionFactory.In(
+ discriminatorColumn,
+ concreteEntityTypes
+ .Select(et => _sqlExpressionFactory.Constant(et.GetDiscriminatorValue(), discriminatorColumn.Type))
+ .ToArray());
selectExpression.ApplyPredicate(predicate);
diff --git a/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs b/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs
index 7ad9ee5b6e1..61abb3e145a 100644
--- a/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs
+++ b/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs
@@ -1185,13 +1185,9 @@ SqlExpression GeneratePredicateTpt(StructuralTypeProjectionExpression entityProj
.Aggregate(_sqlExpressionFactory.OrElse);
}
- return discriminatorValues.Count == 1
- ? _sqlExpressionFactory.Equal(
- entityProjectionExpression.DiscriminatorExpression!,
- _sqlExpressionFactory.Constant(discriminatorValues[0]))
- : _sqlExpressionFactory.In(
- entityProjectionExpression.DiscriminatorExpression!,
- discriminatorValues.Select(d => _sqlExpressionFactory.Constant(d)).ToArray());
+ return _sqlExpressionFactory.In(
+ entityProjectionExpression.DiscriminatorExpression!,
+ discriminatorValues.Select(d => _sqlExpressionFactory.Constant(d)).ToArray());
}
}
else
@@ -1202,15 +1198,11 @@ SqlExpression GeneratePredicateTpt(StructuralTypeProjectionExpression entityProj
{
var concreteEntityTypes = derivedType.GetConcreteDerivedTypesInclusive().ToList();
var discriminatorColumn = BindProperty(typeReference, discriminatorProperty);
- return concreteEntityTypes.Count == 1
- ? _sqlExpressionFactory.Equal(
- discriminatorColumn,
- _sqlExpressionFactory.Constant(concreteEntityTypes[0].GetDiscriminatorValue(), discriminatorColumn.Type))
- : _sqlExpressionFactory.In(
- discriminatorColumn,
- concreteEntityTypes
- .Select(et => _sqlExpressionFactory.Constant(et.GetDiscriminatorValue(), discriminatorColumn.Type))
- .ToArray());
+ return _sqlExpressionFactory.In(
+ discriminatorColumn,
+ concreteEntityTypes
+ .Select(et => _sqlExpressionFactory.Constant(et.GetDiscriminatorValue(), discriminatorColumn.Type))
+ .ToArray());
}
return _sqlExpressionFactory.Constant(true);
diff --git a/src/EFCore.Relational/Query/SqlExpressionFactory.cs b/src/EFCore.Relational/Query/SqlExpressionFactory.cs
index 880e147ece7..d580a748e1f 100644
--- a/src/EFCore.Relational/Query/SqlExpressionFactory.cs
+++ b/src/EFCore.Relational/Query/SqlExpressionFactory.cs
@@ -831,7 +831,9 @@ public virtual SqlExpression In(SqlExpression item, SelectExpression subquery)
///
public virtual SqlExpression In(SqlExpression item, IReadOnlyList values)
- => ApplyTypeMappingOnIn(new InExpression(item, values, _boolTypeMapping));
+ => values is [var singleValue]
+ ? Equal(item, singleValue)
+ : ApplyTypeMappingOnIn(new InExpression(item, values, _boolTypeMapping));
///
public virtual SqlExpression In(SqlExpression item, SqlParameterExpression valuesParameter)
diff --git a/test/EFCore.Cosmos.FunctionalTests/EndToEndCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/EndToEndCosmosTest.cs
index 7ef100ca47a..97436ab1408 100644
--- a/test/EFCore.Cosmos.FunctionalTests/EndToEndCosmosTest.cs
+++ b/test/EFCore.Cosmos.FunctionalTests/EndToEndCosmosTest.cs
@@ -1071,7 +1071,7 @@ await context.AddAsync(
{
var customerFromStore = await context.Set()
.WithPartitionKey(pk1, 3.15m)
- .FirstAsync();
+ .SingleAsync();
Assert.Equal("42", customerFromStore.id);
Assert.Equal("Theon Greyjoy", customerFromStore.Name);
@@ -1135,7 +1135,7 @@ public async Task Can_read_with_find_with_resource_id()
{
var customerFromStore = context.Set()
.WithPartitionKey(pk1, 3.15m)
- .First();
+ .Single();
Assert.Equal("42", customerFromStore.id);
Assert.Equal("Theon Greyjoy", customerFromStore.Name);
@@ -1219,7 +1219,7 @@ await context.AddAsync(
{
var customerFromStore = await context.Set()
.WithPartitionKey(pk1, "One", true)
- .FirstAsync();
+ .SingleAsync();
Assert.Equal(42, customerFromStore.Id);
Assert.Equal("Theon Greyjoy", customerFromStore.Name);
@@ -1288,7 +1288,7 @@ public async Task Can_read_with_find_with_partition_key_and_value_generator()
{
var customerFromStore = context.Set()
.WithPartitionKey(pk1, "One", true)
- .First();
+ .Single();
Assert.Equal(42, customerFromStore.Id);
Assert.Equal("Theon Greyjoy", customerFromStore.Name);
@@ -1344,7 +1344,7 @@ public async Task Can_read_with_find_with_partition_key_without_value_generator(
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "Customer") AND (c["Id"] = @__p_3))
+WHERE (c["Id"] = @__p_3)
OFFSET 0 LIMIT 1
""");
@@ -1357,7 +1357,7 @@ OFFSET 0 LIMIT 1
{
var customerFromStore = context.Set()
.WithPartitionKey(pk1, "One", true)
- .First();
+ .Single();
Assert.Equal(42, customerFromStore.Id);
Assert.Equal("Theon Greyjoy", customerFromStore.Name);
@@ -1489,7 +1489,7 @@ public async Task Can_read_with_find_with_PK_resource_id()
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "CustomerWithResourceId") AND (c["id"] = @__p_0))
+WHERE (c["id"] = @__p_0)
OFFSET 0 LIMIT 1
""");
}
diff --git a/test/EFCore.Cosmos.FunctionalTests/HierarchicalPartitionKeyTest.cs b/test/EFCore.Cosmos.FunctionalTests/HierarchicalPartitionKeyTest.cs
index 1292167d7d5..b068d7f40dc 100644
--- a/test/EFCore.Cosmos.FunctionalTests/HierarchicalPartitionKeyTest.cs
+++ b/test/EFCore.Cosmos.FunctionalTests/HierarchicalPartitionKeyTest.cs
@@ -28,7 +28,6 @@ public virtual async Task Can_add_update_delete_end_to_end_with_partition_key()
"""
SELECT c
FROM root c
-WHERE (c["Discriminator"] = "Customer")
ORDER BY c["PartitionKey1"]
OFFSET 0 LIMIT 1
""";
@@ -39,7 +38,6 @@ OFFSET 0 LIMIT 1
SELECT c
FROM root c
-WHERE (c["Discriminator"] = "Customer")
ORDER BY c["PartitionKey1"]
OFFSET @__p_0 LIMIT 1
""";
@@ -61,14 +59,13 @@ public virtual async Task Can_add_update_delete_end_to_end_with_with_partition_k
"""
SELECT c
FROM root c
-WHERE (c["Discriminator"] = "Customer")
-OFFSET 0 LIMIT 1
+OFFSET 0 LIMIT 2
""";
await PartitionKeyTestAsync(
- ctx => ctx.Customers.WithPartitionKey("A", 1.1, true).FirstAsync(),
+ ctx => ctx.Customers.WithPartitionKey("A", 1.1, true).SingleAsync(),
readSql,
- ctx => ctx.Customers.WithPartitionKey("B", 2.1, false).FirstAsync(),
+ ctx => ctx.Customers.WithPartitionKey("B", 2.1, false).SingleAsync(),
readSql,
ctx => ctx.Customers.WithPartitionKey("B", 2.1, false).LastAsync(),
ctx => ctx.Customers.WithPartitionKey("B", 2.1, false).ToListAsync(),
@@ -82,8 +79,7 @@ public async Task Can_query_with_implicit_partition_key_filter()
"""
SELECT c
FROM root c
-WHERE (c["Discriminator"] = "Customer")
-OFFSET 0 LIMIT 1
+OFFSET 0 LIMIT 2
""";
await PartitionKeyTestAsync(
@@ -93,7 +89,7 @@ await PartitionKeyTestAsync(
&& b.PartitionKey1 == "A"
&& b.PartitionKey2 == 1.1
&& b.PartitionKey3)
- .FirstAsync(),
+ .SingleAsync(),
readSql,
ctx => ctx.Customers
.Where(
@@ -101,7 +97,7 @@ await PartitionKeyTestAsync(
&& b.PartitionKey1 == "B"
&& b.PartitionKey2 == 2.1
&& !b.PartitionKey3)
- .FirstAsync(),
+ .SingleAsync(),
readSql,
ctx => ctx.Customers.WithPartitionKey("B", 2.1, false).LastAsync(),
ctx => ctx.Customers
diff --git a/test/EFCore.Cosmos.FunctionalTests/PartitionKeyTest.cs b/test/EFCore.Cosmos.FunctionalTests/PartitionKeyTest.cs
index a97b30b1252..2e027542742 100644
--- a/test/EFCore.Cosmos.FunctionalTests/PartitionKeyTest.cs
+++ b/test/EFCore.Cosmos.FunctionalTests/PartitionKeyTest.cs
@@ -30,7 +30,6 @@ public virtual async Task Can_add_update_delete_end_to_end_with_partition_key()
"""
SELECT c
FROM root c
-WHERE (c["Discriminator"] = "Customer")
ORDER BY c["PartitionKey"]
OFFSET 0 LIMIT 1
""";
@@ -50,12 +49,11 @@ public virtual async Task Can_add_update_delete_end_to_end_with_with_partition_k
"""
SELECT c
FROM root c
-WHERE (c["Discriminator"] = "Customer")
-OFFSET 0 LIMIT 1
+OFFSET 0 LIMIT 2
""";
await PartitionKeyTestAsync(
- ctx => ctx.Customers.WithPartitionKey("1").FirstAsync(),
+ ctx => ctx.Customers.WithPartitionKey("1").SingleAsync(),
readSql,
ctx => ctx.Customers.WithPartitionKey("2").LastAsync(),
ctx => ctx.Customers.WithPartitionKey("2").ToListAsync(),
@@ -69,7 +67,7 @@ public async Task Can_query_with_implicit_partition_key_filter()
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "Customer") AND ((c["Id"] = 42) OR (c["Name"] = "John Snow")))
+WHERE ((c["Id"] = 42) OR (c["Name"] = "John Snow"))
OFFSET 0 LIMIT 1
""";
diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NonSharedPrimitiveCollectionsQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NonSharedPrimitiveCollectionsQueryCosmosTest.cs
index 08aa9e9d741..8af321be555 100644
--- a/test/EFCore.Cosmos.FunctionalTests/Query/NonSharedPrimitiveCollectionsQueryCosmosTest.cs
+++ b/test/EFCore.Cosmos.FunctionalTests/Query/NonSharedPrimitiveCollectionsQueryCosmosTest.cs
@@ -15,10 +15,10 @@ public override async Task Array_of_string()
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "TestEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM s IN c["SomeArray"]
- WHERE (s = "a")) = 2))
+ WHERE (s = "a")) = 2)
OFFSET 0 LIMIT 2
""");
}
@@ -31,10 +31,10 @@ public override async Task Array_of_int()
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "TestEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM s IN c["SomeArray"]
- WHERE (s = 1)) = 2))
+ WHERE (s = 1)) = 2)
OFFSET 0 LIMIT 2
""");
}
@@ -47,10 +47,10 @@ public override async Task Array_of_long()
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "TestEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM s IN c["SomeArray"]
- WHERE (s = 1)) = 2))
+ WHERE (s = 1)) = 2)
OFFSET 0 LIMIT 2
""");
}
@@ -63,10 +63,10 @@ public override async Task Array_of_short()
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "TestEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM s IN c["SomeArray"]
- WHERE (s = 1)) = 2))
+ WHERE (s = 1)) = 2)
OFFSET 0 LIMIT 2
""");
}
@@ -84,10 +84,10 @@ public override async Task Array_of_double()
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "TestEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM s IN c["SomeArray"]
- WHERE (s = 1.0)) = 2))
+ WHERE (s = 1.0)) = 2)
OFFSET 0 LIMIT 2
""");
}
@@ -100,10 +100,10 @@ public override async Task Array_of_float()
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "TestEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM s IN c["SomeArray"]
- WHERE (s = 1.0)) = 2))
+ WHERE (s = 1.0)) = 2)
OFFSET 0 LIMIT 2
""");
}
@@ -116,10 +116,10 @@ public override async Task Array_of_decimal()
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "TestEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM s IN c["SomeArray"]
- WHERE (s = 1.0)) = 2))
+ WHERE (s = 1.0)) = 2)
OFFSET 0 LIMIT 2
""");
}
@@ -132,10 +132,10 @@ public override async Task Array_of_DateTime()
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "TestEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM s IN c["SomeArray"]
- WHERE (s = "2023-01-01T12:30:00")) = 2))
+ WHERE (s = "2023-01-01T12:30:00")) = 2)
OFFSET 0 LIMIT 2
""");
}
@@ -148,10 +148,10 @@ public override async Task Array_of_DateTime_with_milliseconds()
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "TestEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM s IN c["SomeArray"]
- WHERE (s = "2023-01-01T12:30:00.123")) = 2))
+ WHERE (s = "2023-01-01T12:30:00.123")) = 2)
OFFSET 0 LIMIT 2
""");
}
@@ -164,10 +164,10 @@ public override async Task Array_of_DateTime_with_microseconds()
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "TestEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM s IN c["SomeArray"]
- WHERE (s = "2023-01-01T12:30:00.123456")) = 2))
+ WHERE (s = "2023-01-01T12:30:00.123456")) = 2)
OFFSET 0 LIMIT 2
""");
}
@@ -180,10 +180,10 @@ public override async Task Array_of_DateOnly()
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "TestEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM s IN c["SomeArray"]
- WHERE (s = "2023-01-01")) = 2))
+ WHERE (s = "2023-01-01")) = 2)
OFFSET 0 LIMIT 2
""");
}
@@ -196,10 +196,10 @@ public override async Task Array_of_TimeOnly()
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "TestEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM s IN c["SomeArray"]
- WHERE (s = "12:30:00")) = 2))
+ WHERE (s = "12:30:00")) = 2)
OFFSET 0 LIMIT 2
""");
}
@@ -212,10 +212,10 @@ public override async Task Array_of_TimeOnly_with_milliseconds()
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "TestEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM s IN c["SomeArray"]
- WHERE (s = "12:30:00.123")) = 2))
+ WHERE (s = "12:30:00.123")) = 2)
OFFSET 0 LIMIT 2
""");
}
@@ -228,10 +228,10 @@ public override async Task Array_of_TimeOnly_with_microseconds()
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "TestEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM s IN c["SomeArray"]
- WHERE (s = "12:30:00.123456")) = 2))
+ WHERE (s = "12:30:00.123456")) = 2)
OFFSET 0 LIMIT 2
""");
}
@@ -244,10 +244,10 @@ public override async Task Array_of_DateTimeOffset()
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "TestEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM s IN c["SomeArray"]
- WHERE (s = "2023-01-01T12:30:00+02:00")) = 2))
+ WHERE (s = "2023-01-01T12:30:00+02:00")) = 2)
OFFSET 0 LIMIT 2
""");
}
@@ -260,10 +260,10 @@ public override async Task Array_of_bool()
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "TestEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM s IN c["SomeArray"]
- WHERE (s = true)) = 2))
+ WHERE (s = true)) = 2)
OFFSET 0 LIMIT 2
""");
}
@@ -276,10 +276,10 @@ public override async Task Array_of_Guid()
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "TestEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM s IN c["SomeArray"]
- WHERE (s = "dc8c903d-d655-4144-a0fd-358099d40ae1")) = 2))
+ WHERE (s = "dc8c903d-d655-4144-a0fd-358099d40ae1")) = 2)
OFFSET 0 LIMIT 2
""");
}
@@ -293,10 +293,10 @@ public override async Task Array_of_byte_array()
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "TestEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM s IN c["SomeArray"]
- WHERE (s = "AQI=")) = 2))
+ WHERE (s = "AQI=")) = 2)
OFFSET 0 LIMIT 2
""");
}
@@ -309,10 +309,10 @@ public override async Task Array_of_enum()
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "TestEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM s IN c["SomeArray"]
- WHERE (s = 0)) = 2))
+ WHERE (s = 0)) = 2)
OFFSET 0 LIMIT 2
""");
}
@@ -333,7 +333,7 @@ public override async Task Column_with_custom_converter()
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "TestEntity") AND (c["Ints"] = @__ints_0))
+WHERE (c["Ints"] = @__ints_0)
OFFSET 0 LIMIT 2
""");
}
@@ -361,10 +361,10 @@ public override async Task Inline_collection_in_query_filter()
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "TestEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM a IN (SELECT VALUE [1, 2, 3])
- WHERE (a > c["Id"])) = 1))
+ WHERE (a > c["Id"])) = 1)
OFFSET 0 LIMIT 2
""");
}
diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs
index e29f1608e15..7b12caaaca7 100644
--- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs
+++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs
@@ -2206,7 +2206,7 @@ public override Task IImmutableSet_Contains_with_parameter(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "Customer") AND c["CustomerID"] IN ("ALFKI"))
+WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI"))
""");
});
@@ -2220,7 +2220,7 @@ public override Task IReadOnlySet_Contains_with_parameter(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "Customer") AND c["CustomerID"] IN ("ALFKI"))
+WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI"))
""");
});
diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/PrimitiveCollectionsQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/PrimitiveCollectionsQueryCosmosTest.cs
index aa642d076b3..de0e74fb1e9 100644
--- a/test/EFCore.Cosmos.FunctionalTests/Query/PrimitiveCollectionsQueryCosmosTest.cs
+++ b/test/EFCore.Cosmos.FunctionalTests/Query/PrimitiveCollectionsQueryCosmosTest.cs
@@ -29,7 +29,7 @@ public override Task Inline_collection_of_ints_Contains(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND c["Int"] IN (10, 999))
+WHERE c["Int"] IN (10, 999)
""");
});
@@ -43,7 +43,7 @@ public override Task Inline_collection_of_nullable_ints_Contains(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND c["NullableInt"] IN (10, 999))
+WHERE c["NullableInt"] IN (10, 999)
""");
});
@@ -57,7 +57,7 @@ public override Task Inline_collection_of_nullable_ints_Contains_null(bool async
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND c["NullableInt"] IN (null, 999))
+WHERE c["NullableInt"] IN (null, 999)
""");
});
@@ -71,10 +71,10 @@ public override Task Inline_collection_Count_with_zero_values(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM a IN (SELECT VALUE [])
- WHERE (a > c["Id"])) = 1))
+ WHERE (a > c["Id"])) = 1)
""");
});
@@ -88,10 +88,10 @@ public override Task Inline_collection_Count_with_one_value(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM a IN (SELECT VALUE [2])
- WHERE (a > c["Id"])) = 1))
+ WHERE (a > c["Id"])) = 1)
""");
});
@@ -105,10 +105,10 @@ public override Task Inline_collection_Count_with_two_values(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM a IN (SELECT VALUE [2, 999])
- WHERE (a > c["Id"])) = 1))
+ WHERE (a > c["Id"])) = 1)
""");
});
@@ -122,10 +122,10 @@ public override Task Inline_collection_Count_with_three_values(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM a IN (SELECT VALUE [2, 999, 1000])
- WHERE (a > c["Id"])) = 2))
+ WHERE (a > c["Id"])) = 2)
""");
});
@@ -139,7 +139,7 @@ public override Task Inline_collection_Contains_with_zero_values(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND false)
+WHERE false
""");
});
@@ -153,7 +153,7 @@ public override Task Inline_collection_Contains_with_one_value(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND c["Id"] IN (2))
+WHERE (c["Id"] = 2)
""");
});
@@ -167,7 +167,7 @@ public override Task Inline_collection_Contains_with_two_values(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND c["Id"] IN (2, 999))
+WHERE c["Id"] IN (2, 999)
""");
});
@@ -181,7 +181,7 @@ public override Task Inline_collection_Contains_with_three_values(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND c["Id"] IN (2, 999, 1000))
+WHERE c["Id"] IN (2, 999, 1000)
""");
});
@@ -195,7 +195,7 @@ public override Task Inline_collection_Contains_with_EF_Constant(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND c["Id"] IN (2, 999, 1000))
+WHERE c["Id"] IN (2, 999, 1000)
""");
});
@@ -212,7 +212,7 @@ public override Task Inline_collection_Contains_with_all_parameters(bool async)
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND c["Id"] IN (@__i_0, @__j_1))
+WHERE c["Id"] IN (@__i_0, @__j_1)
""");
});
@@ -228,7 +228,7 @@ public override Task Inline_collection_Contains_with_constant_and_parameter(bool
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND c["Id"] IN (2, @__j_0))
+WHERE c["Id"] IN (2, @__j_0)
""");
});
@@ -244,7 +244,7 @@ public override Task Inline_collection_Contains_with_mixed_value_types(bool asyn
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND c["Int"] IN (999, @__i_0, c["Id"], (c["Id"] + c["Int"])))
+WHERE c["Int"] IN (999, @__i_0, c["Id"], (c["Id"] + c["Int"]))
""");
});
@@ -260,7 +260,7 @@ public override Task Inline_collection_List_Contains_with_mixed_value_types(bool
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND c["Int"] IN (999, @__i_0, c["Id"], (c["Id"] + c["Int"])))
+WHERE c["Int"] IN (999, @__i_0, c["Id"], (c["Id"] + c["Int"]))
""");
});
@@ -274,7 +274,7 @@ public override Task Inline_collection_Contains_as_Any_with_predicate(bool async
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND c["Id"] IN (2, 999))
+WHERE c["Id"] IN (2, 999)
""");
});
@@ -288,7 +288,7 @@ public override Task Inline_collection_negated_Contains_as_All(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND c["Id"] NOT IN (2, 999))
+WHERE c["Id"] NOT IN (2, 999)
""");
});
@@ -302,9 +302,9 @@ public override Task Inline_collection_Min_with_two_values(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ((
+WHERE ((
SELECT VALUE MIN(a)
- FROM a IN (SELECT VALUE [30, c["Int"]])) = 30))
+ FROM a IN (SELECT VALUE [30, c["Int"]])) = 30)
""");
});
@@ -318,9 +318,9 @@ public override Task Inline_collection_List_Min_with_two_values(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ((
+WHERE ((
SELECT VALUE MIN(a)
- FROM a IN (SELECT VALUE [30, c["Int"]])) = 30))
+ FROM a IN (SELECT VALUE [30, c["Int"]])) = 30)
""");
});
@@ -334,9 +334,9 @@ public override Task Inline_collection_Max_with_two_values(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ((
+WHERE ((
SELECT VALUE MAX(a)
- FROM a IN (SELECT VALUE [30, c["Int"]])) = 30))
+ FROM a IN (SELECT VALUE [30, c["Int"]])) = 30)
""");
});
@@ -350,9 +350,9 @@ public override Task Inline_collection_List_Max_with_two_values(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ((
+WHERE ((
SELECT VALUE MAX(a)
- FROM a IN (SELECT VALUE [30, c["Int"]])) = 30))
+ FROM a IN (SELECT VALUE [30, c["Int"]])) = 30)
""");
});
@@ -368,9 +368,9 @@ public override Task Inline_collection_Min_with_three_values(bool async)
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ((
+WHERE ((
SELECT VALUE MIN(a)
- FROM a IN (SELECT VALUE [30, c["Int"], @__i_0])) = 25))
+ FROM a IN (SELECT VALUE [30, c["Int"], @__i_0])) = 25)
""");
});
@@ -386,9 +386,9 @@ public override Task Inline_collection_List_Min_with_three_values(bool async)
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ((
+WHERE ((
SELECT VALUE MIN(a)
- FROM a IN (SELECT VALUE [30, c["Int"], @__i_0])) = 25))
+ FROM a IN (SELECT VALUE [30, c["Int"], @__i_0])) = 25)
""");
});
@@ -404,9 +404,9 @@ public override Task Inline_collection_Max_with_three_values(bool async)
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ((
+WHERE ((
SELECT VALUE MAX(a)
- FROM a IN (SELECT VALUE [30, c["Int"], @__i_0])) = 35))
+ FROM a IN (SELECT VALUE [30, c["Int"], @__i_0])) = 35)
""");
});
@@ -422,9 +422,9 @@ public override Task Inline_collection_List_Max_with_three_values(bool async)
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ((
+WHERE ((
SELECT VALUE MAX(a)
- FROM a IN (SELECT VALUE [30, c["Int"], @__i_0])) = 35))
+ FROM a IN (SELECT VALUE [30, c["Int"], @__i_0])) = 35)
""");
});
@@ -440,10 +440,10 @@ public override Task Parameter_collection_Count(bool async)
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM i IN (SELECT VALUE @__ids_0)
- WHERE (i > c["Id"])) = 1))
+ WHERE (i > c["Id"])) = 1)
""");
});
@@ -459,7 +459,7 @@ public override Task Parameter_collection_of_ints_Contains_int(bool async)
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(@__ints_0, c["Int"]))
+WHERE ARRAY_CONTAINS(@__ints_0, c["Int"])
""",
//
"""
@@ -467,7 +467,7 @@ FROM root c
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND NOT(ARRAY_CONTAINS(@__ints_0, c["Int"])))
+WHERE NOT(ARRAY_CONTAINS(@__ints_0, c["Int"]))
""");
});
@@ -483,7 +483,7 @@ public override Task Parameter_collection_HashSet_of_ints_Contains_int(bool asyn
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(@__ints_0, c["Int"]))
+WHERE ARRAY_CONTAINS(@__ints_0, c["Int"])
""",
//
"""
@@ -491,7 +491,7 @@ FROM root c
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND NOT(ARRAY_CONTAINS(@__ints_0, c["Int"])))
+WHERE NOT(ARRAY_CONTAINS(@__ints_0, c["Int"]))
""");
});
@@ -507,7 +507,7 @@ public override Task Parameter_collection_of_ints_Contains_nullable_int(bool asy
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(@__ints_0, c["NullableInt"]))
+WHERE ARRAY_CONTAINS(@__ints_0, c["NullableInt"])
""",
//
"""
@@ -515,7 +515,7 @@ FROM root c
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND NOT(ARRAY_CONTAINS(@__ints_0, c["NullableInt"])))
+WHERE NOT(ARRAY_CONTAINS(@__ints_0, c["NullableInt"]))
""");
});
@@ -531,7 +531,7 @@ public override Task Parameter_collection_of_nullable_ints_Contains_int(bool asy
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(@__nullableInts_0, c["Int"]))
+WHERE ARRAY_CONTAINS(@__nullableInts_0, c["Int"])
""",
//
"""
@@ -539,7 +539,7 @@ FROM root c
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND NOT(ARRAY_CONTAINS(@__nullableInts_0, c["Int"])))
+WHERE NOT(ARRAY_CONTAINS(@__nullableInts_0, c["Int"]))
""");
});
@@ -555,7 +555,7 @@ public override Task Parameter_collection_of_nullable_ints_Contains_nullable_int
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(@__nullableInts_0, c["NullableInt"]))
+WHERE ARRAY_CONTAINS(@__nullableInts_0, c["NullableInt"])
""",
//
"""
@@ -563,7 +563,7 @@ FROM root c
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND NOT(ARRAY_CONTAINS(@__nullableInts_0, c["NullableInt"])))
+WHERE NOT(ARRAY_CONTAINS(@__nullableInts_0, c["NullableInt"]))
""");
});
@@ -579,7 +579,7 @@ public override Task Parameter_collection_of_strings_Contains_string(bool async)
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(@__strings_0, c["String"]))
+WHERE ARRAY_CONTAINS(@__strings_0, c["String"])
""",
//
"""
@@ -587,7 +587,7 @@ FROM root c
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND NOT(ARRAY_CONTAINS(@__strings_0, c["String"])))
+WHERE NOT(ARRAY_CONTAINS(@__strings_0, c["String"]))
""");
});
@@ -603,7 +603,7 @@ public override Task Parameter_collection_of_strings_Contains_nullable_string(bo
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(@__strings_0, c["NullableString"]))
+WHERE ARRAY_CONTAINS(@__strings_0, c["NullableString"])
""",
//
"""
@@ -611,7 +611,7 @@ FROM root c
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND NOT(ARRAY_CONTAINS(@__strings_0, c["NullableString"])))
+WHERE NOT(ARRAY_CONTAINS(@__strings_0, c["NullableString"]))
""");
});
@@ -627,7 +627,7 @@ public override Task Parameter_collection_of_nullable_strings_Contains_string(bo
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(@__strings_0, c["String"]))
+WHERE ARRAY_CONTAINS(@__strings_0, c["String"])
""",
//
"""
@@ -635,7 +635,7 @@ FROM root c
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND NOT(ARRAY_CONTAINS(@__strings_0, c["String"])))
+WHERE NOT(ARRAY_CONTAINS(@__strings_0, c["String"]))
""");
});
@@ -651,7 +651,7 @@ public override Task Parameter_collection_of_nullable_strings_Contains_nullable_
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(@__strings_0, c["NullableString"]))
+WHERE ARRAY_CONTAINS(@__strings_0, c["NullableString"])
""",
//
"""
@@ -659,7 +659,7 @@ FROM root c
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND NOT(ARRAY_CONTAINS(@__strings_0, c["NullableString"])))
+WHERE NOT(ARRAY_CONTAINS(@__strings_0, c["NullableString"]))
""");
});
@@ -675,7 +675,7 @@ public override Task Parameter_collection_of_DateTimes_Contains(bool async)
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(@__dateTimes_0, c["DateTime"]))
+WHERE ARRAY_CONTAINS(@__dateTimes_0, c["DateTime"])
""");
});
@@ -691,7 +691,7 @@ public override Task Parameter_collection_of_bools_Contains(bool async)
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(@__bools_0, c["Bool"]))
+WHERE ARRAY_CONTAINS(@__bools_0, c["Bool"])
""");
});
@@ -707,7 +707,7 @@ public override Task Parameter_collection_of_enums_Contains(bool async)
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(@__enums_0, c["Enum"]))
+WHERE ARRAY_CONTAINS(@__enums_0, c["Enum"])
""");
});
@@ -723,7 +723,7 @@ public override Task Parameter_collection_null_Contains(bool async)
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(@__ints_0, c["Int"]))
+WHERE ARRAY_CONTAINS(@__ints_0, c["Int"])
""");
});
@@ -737,7 +737,7 @@ public override Task Column_collection_of_ints_Contains(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(c["Ints"], 10))
+WHERE ARRAY_CONTAINS(c["Ints"], 10)
""");
});
@@ -751,7 +751,7 @@ public override Task Column_collection_of_nullable_ints_Contains(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(c["NullableInts"], 10))
+WHERE ARRAY_CONTAINS(c["NullableInts"], 10)
""");
});
@@ -765,7 +765,7 @@ public override Task Column_collection_of_nullable_ints_Contains_null(bool async
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(c["NullableInts"], null))
+WHERE ARRAY_CONTAINS(c["NullableInts"], null)
""");
});
@@ -779,7 +779,7 @@ public override Task Column_collection_of_strings_contains_null(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(c["Strings"], null))
+WHERE ARRAY_CONTAINS(c["Strings"], null)
""");
});
@@ -793,7 +793,7 @@ public override Task Column_collection_of_nullable_strings_contains_null(bool as
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(c["NullableStrings"], null))
+WHERE ARRAY_CONTAINS(c["NullableStrings"], null)
""");
});
@@ -807,7 +807,7 @@ public override Task Column_collection_of_bools_Contains(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(c["Bools"], true))
+WHERE ARRAY_CONTAINS(c["Bools"], true)
""");
});
@@ -821,7 +821,7 @@ public override Task Column_collection_Count_method(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (ARRAY_LENGTH(c["Ints"]) = 2))
+WHERE (ARRAY_LENGTH(c["Ints"]) = 2)
""");
});
@@ -835,7 +835,7 @@ public override Task Column_collection_Length(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (ARRAY_LENGTH(c["Ints"]) = 2))
+WHERE (ARRAY_LENGTH(c["Ints"]) = 2)
""");
});
@@ -849,10 +849,10 @@ public override Task Column_collection_Count_with_predicate(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM i IN c["Ints"]
- WHERE (i > 1)) = 2))
+ WHERE (i > 1)) = 2)
""");
});
@@ -866,10 +866,10 @@ public override Task Column_collection_Where_Count(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ((
+WHERE ((
SELECT VALUE COUNT(1)
FROM i IN c["Ints"]
- WHERE (i > 1)) = 2))
+ WHERE (i > 1)) = 2)
""");
});
@@ -883,7 +883,7 @@ public override Task Column_collection_index_int(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (c["Ints"][1] = 10))
+WHERE (c["Ints"][1] = 10)
""");
});
@@ -897,7 +897,7 @@ public override Task Column_collection_index_string(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (c["Strings"][1] = "10"))
+WHERE (c["Strings"][1] = "10")
""");
});
@@ -911,7 +911,7 @@ public override Task Column_collection_index_datetime(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (c["DateTimes"][1] = "2020-01-10T12:30:00Z"))
+WHERE (c["DateTimes"][1] = "2020-01-10T12:30:00Z")
""");
});
@@ -925,7 +925,7 @@ public override Task Column_collection_index_beyond_end(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (c["Ints"][999] = 10))
+WHERE (c["Ints"][999] = 10)
""");
});
@@ -940,7 +940,7 @@ public override async Task Nullable_reference_column_collection_index_equals_nul
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (c["NullableStrings"][2] = c["NullableString"]))
+WHERE (c["NullableStrings"][2] = c["NullableString"])
""");
}
}
@@ -955,7 +955,7 @@ public override Task Non_nullable_reference_column_collection_index_equals_nulla
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ((ARRAY_LENGTH(c["Strings"]) > 0) AND (c["Strings"][1] = c["NullableString"])))
+WHERE ((ARRAY_LENGTH(c["Strings"]) > 0) AND (c["Strings"][1] = c["NullableString"]))
""");
});
@@ -973,7 +973,7 @@ public override async Task Inline_collection_index_Column(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ([1, 2, 3][c["Int"]] = 1))
+WHERE ([1, 2, 3][c["Int"]] = 1)
""");
}
}
@@ -992,7 +992,7 @@ public override async Task Inline_collection_value_index_Column(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ([1, c["Int"], 3][c["Int"]] = 1))
+WHERE ([1, c["Int"], 3][c["Int"]] = 1)
""");
}
}
@@ -1011,7 +1011,7 @@ public override async Task Inline_collection_List_value_index_Column(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ([1, c["Int"], 3][c["Int"]] = 1))
+WHERE ([1, c["Int"], 3][c["Int"]] = 1)
""");
}
}
@@ -1032,7 +1032,7 @@ public override async Task Parameter_collection_index_Column_equal_Column(bool a
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (@__ints_0[c["Int"]] = c["Int"]))
+WHERE (@__ints_0[c["Int"]] = c["Int"])
""");
}
}
@@ -1053,7 +1053,7 @@ public override async Task Parameter_collection_index_Column_equal_constant(bool
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (@__ints_0[c["Int"]] = 1))
+WHERE (@__ints_0[c["Int"]] = 1)
""");
}
}
@@ -1068,7 +1068,7 @@ public override Task Column_collection_ElementAt(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (c["Ints"][1] = 10))
+WHERE (c["Ints"][1] = 10)
""");
});
@@ -1082,7 +1082,7 @@ public override Task Column_collection_First(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (c["Ints"][0] = 1))
+WHERE (c["Ints"][0] = 1)
""");
});
@@ -1096,7 +1096,7 @@ public override Task Column_collection_FirstOrDefault(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ((c["Ints"][0] ?? 0) = 1))
+WHERE ((c["Ints"][0] ?? 0) = 1)
""");
});
@@ -1110,7 +1110,7 @@ public override Task Column_collection_Single(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (c["Ints"][0] = 1))
+WHERE (c["Ints"][0] = 1)
""");
});
@@ -1124,7 +1124,7 @@ public override Task Column_collection_SingleOrDefault(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ((c["Ints"][0] ?? 0) = 1))
+WHERE ((c["Ints"][0] ?? 0) = 1)
""");
});
@@ -1138,7 +1138,7 @@ public override Task Column_collection_Skip(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (ARRAY_LENGTH(ARRAY_SLICE(c["Ints"], 1)) = 2))
+WHERE (ARRAY_LENGTH(ARRAY_SLICE(c["Ints"], 1)) = 2)
""");
});
@@ -1152,7 +1152,7 @@ public override Task Column_collection_Take(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(ARRAY_SLICE(c["Ints"], 0, 2), 11))
+WHERE ARRAY_CONTAINS(ARRAY_SLICE(c["Ints"], 0, 2), 11)
""");
});
@@ -1166,7 +1166,7 @@ public override Task Column_collection_Skip_Take(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(ARRAY_SLICE(c["Ints"], 1, 2), 11))
+WHERE ARRAY_CONTAINS(ARRAY_SLICE(c["Ints"], 1, 2), 11)
""");
});
@@ -1180,10 +1180,10 @@ public override Task Column_collection_Where_Skip(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (ARRAY_LENGTH(ARRAY_SLICE(ARRAY(
+WHERE (ARRAY_LENGTH(ARRAY_SLICE(ARRAY(
SELECT VALUE i
FROM i IN c["Ints"]
- WHERE (i > 1)), 1)) = 3))
+ WHERE (i > 1)), 1)) = 3)
""");
});
@@ -1197,10 +1197,10 @@ public override Task Column_collection_Where_Take(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (ARRAY_LENGTH(ARRAY_SLICE(ARRAY(
+WHERE (ARRAY_LENGTH(ARRAY_SLICE(ARRAY(
SELECT VALUE i
FROM i IN c["Ints"]
- WHERE (i > 1)), 0, 2)) = 2))
+ WHERE (i > 1)), 0, 2)) = 2)
""");
});
@@ -1214,10 +1214,10 @@ public override Task Column_collection_Where_Skip_Take(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (ARRAY_LENGTH(ARRAY_SLICE(ARRAY(
+WHERE (ARRAY_LENGTH(ARRAY_SLICE(ARRAY(
SELECT VALUE i
FROM i IN c["Ints"]
- WHERE (i > 1)), 1, 2)) = 1))
+ WHERE (i > 1)), 1, 2)) = 1)
""");
});
@@ -1231,10 +1231,10 @@ public override Task Column_collection_Contains_over_subquery(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND EXISTS (
+WHERE EXISTS (
SELECT 1
FROM i IN c["Ints"]
- WHERE ((i > 1) AND (i = 11))))
+ WHERE ((i > 1) AND (i = 11)))
""");
});
@@ -1252,10 +1252,10 @@ public override async Task Column_collection_OrderByDescending_ElementAt(bool as
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (ARRAY(
+WHERE (ARRAY(
SELECT VALUE i
FROM i IN c["Ints"]
- ORDER BY i DESC)[0] = 111))
+ ORDER BY i DESC)[0] = 111)
""");
}
}
@@ -1270,10 +1270,10 @@ public override Task Column_collection_Where_ElementAt(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (ARRAY(
+WHERE (ARRAY(
SELECT VALUE i
FROM i IN c["Ints"]
- WHERE (i > 1))[0] = 11))
+ WHERE (i > 1))[0] = 11)
""");
});
@@ -1287,7 +1287,7 @@ public override Task Column_collection_Any(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (ARRAY_LENGTH(c["Ints"]) > 0))
+WHERE (ARRAY_LENGTH(c["Ints"]) > 0)
""");
});
@@ -1310,7 +1310,6 @@ public override Task Column_collection_SelectMany(bool async)
SELECT i AS i0
FROM root c
JOIN i IN c["Ints"]
-WHERE (c["Discriminator"] = "PrimitiveCollectionsEntity")
""");
});
@@ -1328,7 +1327,6 @@ FROM root c
SELECT VALUE i
FROM i IN c["Ints"]
WHERE (i > 1)) j
-WHERE (c["Discriminator"] = "PrimitiveCollectionsEntity")
""");
});
@@ -1355,7 +1353,6 @@ public override Task Column_collection_projection_from_top_level(bool async)
"""
SELECT c["Ints"]
FROM root c
-WHERE (c["Discriminator"] = "PrimitiveCollectionsEntity")
ORDER BY c["Id"]
""");
});
@@ -1388,7 +1385,7 @@ public override Task Parameter_collection_Concat_column_collection(bool async)
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (ARRAY_LENGTH(ARRAY_CONCAT(@__ints_0, c["Ints"])) = 2))
+WHERE (ARRAY_LENGTH(ARRAY_CONCAT(@__ints_0, c["Ints"])) = 2)
""");
});
@@ -1404,7 +1401,7 @@ public override Task Column_collection_Union_parameter_collection(bool async)
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (ARRAY_LENGTH(SetUnion(c["Ints"], @__ints_0)) = 2))
+WHERE (ARRAY_LENGTH(SetUnion(c["Ints"], @__ints_0)) = 2)
""");
});
@@ -1418,7 +1415,7 @@ public override Task Column_collection_Intersect_inline_collection(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (ARRAY_LENGTH(SetIntersect(c["Ints"], [11, 111])) = 2))
+WHERE (ARRAY_LENGTH(SetIntersect(c["Ints"], [11, 111])) = 2)
""");
});
@@ -1441,10 +1438,10 @@ public override Task Column_collection_Where_Union(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (ARRAY_LENGTH(SetUnion(ARRAY(
+WHERE (ARRAY_LENGTH(SetUnion(ARRAY(
SELECT VALUE i
FROM i IN c["Ints"]
- WHERE (i > 100)), [50])) = 2))
+ WHERE (i > 100)), [50])) = 2)
""");
});
@@ -1460,7 +1457,7 @@ public override Task Column_collection_equality_parameter_collection(bool async)
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (c["Ints"] = @__ints_0))
+WHERE (c["Ints"] = @__ints_0)
""");
});
@@ -1476,7 +1473,7 @@ public override Task Column_collection_Concat_parameter_collection_equality_inli
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (ARRAY_CONCAT(c["Ints"], @__ints_0) = [1,11,111,1,10]))
+WHERE (ARRAY_CONCAT(c["Ints"], @__ints_0) = [1,11,111,1,10])
""");
});
@@ -1490,7 +1487,7 @@ public override Task Column_collection_equality_inline_collection(bool async)
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (c["Ints"] = [1,10]))
+WHERE (c["Ints"] = [1,10])
""");
});
@@ -1507,7 +1504,7 @@ public override Task Column_collection_equality_inline_collection_with_parameter
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (c["Ints"] = [@__i_0, @__j_1]))
+WHERE (c["Ints"] = [@__i_0, @__j_1])
""");
});
@@ -1521,10 +1518,10 @@ public override Task Column_collection_Where_equality_inline_collection(bool asy
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (ARRAY(
+WHERE (ARRAY(
SELECT VALUE i
FROM i IN c["Ints"]
- WHERE (i != 11)) = [1,111]))
+ WHERE (i != 11)) = [1,111])
""");
});
@@ -1552,7 +1549,7 @@ public override Task Parameter_collection_in_subquery_Union_column_collection(bo
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (ARRAY_LENGTH(SetUnion(@__Skip_0, c["Ints"])) = 3))
+WHERE (ARRAY_LENGTH(SetUnion(@__Skip_0, c["Ints"])) = 3)
""");
});
@@ -1619,7 +1616,6 @@ public override Task Project_collection_of_ints_simple(bool async)
"""
SELECT c["Ints"]
FROM root c
-WHERE (c["Discriminator"] = "PrimitiveCollectionsEntity")
ORDER BY c["Id"]
""");
});
@@ -1641,7 +1637,6 @@ SELECT VALUE i
FROM i IN c["Ints"]
ORDER BY i DESC) AS c
FROM root c
-WHERE (c["Discriminator"] = "PrimitiveCollectionsEntity")
ORDER BY c["Id"]
""");
}
@@ -1660,7 +1655,6 @@ SELECT VALUE d
FROM d IN c["DateTimes"]
WHERE (DateTimePart("dd", d) != 1)) AS c
FROM root c
-WHERE (c["Discriminator"] = "PrimitiveCollectionsEntity")
ORDER BY c["Id"]
""");
});
@@ -1713,7 +1707,6 @@ SELECT ARRAY(
SELECT DISTINCT VALUE i
FROM i IN c["Ints"]) AS c
FROM root c
-WHERE (c["Discriminator"] = "PrimitiveCollectionsEntity")
ORDER BY c["Id"]
""");
});
@@ -1745,7 +1738,6 @@ SELECT ARRAY(
SELECT VALUE i
FROM i IN c["Ints"]) AS c
FROM root c
-WHERE (c["Discriminator"] = "PrimitiveCollectionsEntity")
ORDER BY c["Id"]
OFFSET 0 LIMIT 1
""");
@@ -1771,7 +1763,6 @@ FROM n0 IN c["NullableInts"]
WHERE (n0 = null))
}
FROM root c
-WHERE (c["Discriminator"] = "PrimitiveCollectionsEntity")
ORDER BY c["Id"]
""");
});
@@ -1807,7 +1798,6 @@ FROM d0 IN c["DateTimes"]
WHERE (d0 > "2000-01-01T00:00:00"))
}
FROM root c
-WHERE (c["Discriminator"] = "PrimitiveCollectionsEntity")
ORDER BY c["Id"]
""");
}
@@ -1828,7 +1818,7 @@ SELECT VALUE
"QueryableElementAt" : c["Strings"][1]
}
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND (c["Id"] < 4))
+WHERE (c["Id"] < 4)
ORDER BY c["Id"]
""");
});
@@ -1844,7 +1834,6 @@ public override Task Project_inline_collection(bool async)
"""
SELECT [c["String"], "foo"] AS c
FROM root c
-WHERE (c["Discriminator"] = "PrimitiveCollectionsEntity")
""");
});
@@ -1881,7 +1870,7 @@ public override Task Nested_contains_with_Lists_and_no_inferred_type_mapping(boo
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(@__strings_1, (ARRAY_CONTAINS(@__ints_0, c["Int"]) ? "one" : "two")))
+WHERE ARRAY_CONTAINS(@__strings_1, (ARRAY_CONTAINS(@__ints_0, c["Int"]) ? "one" : "two"))
""");
});
@@ -1898,7 +1887,7 @@ public override Task Nested_contains_with_arrays_and_no_inferred_type_mapping(bo
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ARRAY_CONTAINS(@__strings_1, (ARRAY_CONTAINS(@__ints_0, c["Int"]) ? "one" : "two")))
+WHERE ARRAY_CONTAINS(@__strings_1, (ARRAY_CONTAINS(@__ints_0, c["Int"]) ? "one" : "two"))
""");
});
@@ -1919,7 +1908,7 @@ await AssertQuery(
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND IS_DEFINED(c["Ints"][2]))
+WHERE IS_DEFINED(c["Ints"][2])
""");
});
@@ -1938,7 +1927,7 @@ await AssertQuery(
"""
SELECT c
FROM root c
-WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND ((c["Ints"][2] ?? 999) = 999))
+WHERE ((c["Ints"][2] ?? 999) = 999)
""");
});
diff --git a/test/EFCore.Cosmos.FunctionalTests/ReloadTest.cs b/test/EFCore.Cosmos.FunctionalTests/ReloadTest.cs
index 33094e6724b..5965397444f 100644
--- a/test/EFCore.Cosmos.FunctionalTests/ReloadTest.cs
+++ b/test/EFCore.Cosmos.FunctionalTests/ReloadTest.cs
@@ -64,12 +64,14 @@ public TestSqlLoggerFactory TestSqlLoggerFactory
public class ReloadTestContext(DbContextOptions dbContextOptions) : DbContext(dbContextOptions)
{
protected override void OnModelCreating(ModelBuilder modelBuilder)
+ => modelBuilder.Entity- (b => b.HasPartitionKey(e => e.Id));
+
+ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
- modelBuilder.Entity
- (
- b =>
- {
- b.HasPartitionKey(e => e.Id);
- });
+ base.OnConfiguring(optionsBuilder);
+
+ // TODO: Remove this after #33893 - once Reload is implemented via ReadItem, the warning shouldn't be emitted
+ optionsBuilder.ConfigureWarnings(w => w.Log(CoreEventId.FirstWithoutOrderByAndFilterWarning));
}
public DbSet
- Items { get; set; }
diff --git a/test/EFCore.Cosmos.Tests/Infrastructure/CosmosModelValidatorTest.cs b/test/EFCore.Cosmos.Tests/Infrastructure/CosmosModelValidatorTest.cs
index 0feeb9a8184..6a65e2d667e 100644
--- a/test/EFCore.Cosmos.Tests/Infrastructure/CosmosModelValidatorTest.cs
+++ b/test/EFCore.Cosmos.Tests/Infrastructure/CosmosModelValidatorTest.cs
@@ -239,6 +239,19 @@ public virtual void Detects_partition_key_of_different_type()
VerifyError(CosmosStrings.PartitionKeyBadStoreType("foo", nameof(Customer), "JObject"), modelBuilder);
}
+ [ConditionalFact]
+ public virtual void Detects_conflicting_IsDiscriminatorMappingCompleteMismatch()
+ {
+ var modelBuilder = CreateConventionModelBuilder();
+ modelBuilder.Entity().ToContainer("Orders")
+ .Metadata.SetDiscriminatorMappingComplete(true);
+ modelBuilder.Entity().ToContainer("Orders")
+ .Metadata.SetDiscriminatorMappingComplete(false);
+
+ VerifyError(
+ CosmosStrings.IsDiscriminatorMappingCompleteMismatch(true, nameof(Customer), nameof(Order), false, "Orders"), modelBuilder);
+ }
+
[ConditionalFact]
public virtual void Detects_conflicting_analytical_ttl()
{