Skip to content

Commit 596ef7e

Browse files
committed
Remove redundant casts (automated)
1 parent 1016470 commit 596ef7e

7 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/EFCore.PG.NodaTime/Storage/Internal/TimestampLocalDateTimeMapping.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ internal static Expression GenerateCodeLiteral(LocalDateTime dateTime)
6969
var newExpr = ConstantNew(ConstructorWithSeconds, dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second);
7070

7171
return dateTime.NanosecondOfSecond == 0
72-
? (Expression)newExpr
72+
? newExpr
7373
: Expression.Call(newExpr, PlusNanosecondsMethod, Expression.Constant((long)dateTime.NanosecondOfSecond));
7474
}
7575
}

src/EFCore.PG/Query/NpgsqlSqlExpressionFactory.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public virtual PostgresBinaryExpression AtTimeZone(
7575
// PostgreSQL AT TIME ZONE flips the given type from timestamptz to timestamp and vice versa
7676
// See https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-ZONECONVERT
7777
typeMapping ??= FlipTimestampTypeMapping(
78-
timestamp.TypeMapping ?? (RelationalTypeMapping?)_typeMappingSource.FindMapping(timestamp.Type, Dependencies.Model)!);
78+
timestamp.TypeMapping ?? _typeMappingSource.FindMapping(timestamp.Type, Dependencies.Model)!);
7979

8080
return new PostgresBinaryExpression(
8181
PostgresExpressionType.AtTimeZone,
@@ -613,7 +613,7 @@ private SqlExpression ApplyTypeMappingOnArrayIndex(
613613
postgresArrayIndexExpression.Array.TypeMapping is NpgsqlArrayTypeMapping arrayMapping
614614
? arrayMapping.ElementMapping
615615
: typeMapping
616-
?? (RelationalTypeMapping?)_typeMappingSource.FindMapping(postgresArrayIndexExpression.Type, Dependencies.Model));
616+
?? _typeMappingSource.FindMapping(postgresArrayIndexExpression.Type, Dependencies.Model));
617617
}
618618

619619
private SqlExpression ApplyTypeMappingOnILike(PostgresILikeExpression ilikeExpression)
@@ -624,7 +624,7 @@ private SqlExpression ApplyTypeMappingOnILike(PostgresILikeExpression ilikeExpre
624624
: ExpressionExtensions.InferTypeMapping(
625625
ilikeExpression.Match, ilikeExpression.Pattern,
626626
ilikeExpression.EscapeChar))
627-
?? (RelationalTypeMapping?)_typeMappingSource.FindMapping(ilikeExpression.Match.Type, Dependencies.Model);
627+
?? _typeMappingSource.FindMapping(ilikeExpression.Match.Type, Dependencies.Model);
628628

629629
return new PostgresILikeExpression(
630630
ApplyTypeMapping(ilikeExpression.Match, inferredTypeMapping),

src/EFCore.PG/Storage/Internal/NpgsqlTypeMappingSource.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ protected virtual void SetupEnumMappings(ISqlGenerationHelper sqlGenerationHelpe
613613
var elementType = clrType.GetElementType();
614614
Debug.Assert(elementType is not null, "Detected array type but element type is null");
615615

616-
var elementMapping = (RelationalTypeMapping?)FindMapping(elementType);
616+
var elementMapping = FindMapping(elementType);
617617

618618
// If no mapping was found for the element, there's no mapping for the array.
619619
// Also, arrays of arrays aren't supported (as opposed to multidimensional arrays) by PostgreSQL
@@ -636,7 +636,7 @@ protected virtual void SetupEnumMappings(ISqlGenerationHelper sqlGenerationHelpe
636636
var elementType = clrType.GetGenericArguments()[0];
637637

638638
// If an element isn't supported, neither is its array
639-
var elementMapping = (RelationalTypeMapping?)FindMapping(elementType);
639+
var elementMapping = FindMapping(elementType);
640640
if (elementMapping is null)
641641
{
642642
return null;

test/EFCore.PG.NodaTime.FunctionalTests/LegacyNpgsqlNodaTimeTypeMappingTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void GenerateSqlLiteral_returns_instant_range_in_legacy_mode()
7272

7373
private static RelationalTypeMapping GetMapping(string storeType) => Mapper.FindMapping(storeType);
7474

75-
private static RelationalTypeMapping GetMapping(Type clrType) => (RelationalTypeMapping)Mapper.FindMapping(clrType);
75+
private static RelationalTypeMapping GetMapping(Type clrType) => Mapper.FindMapping(clrType);
7676

7777
private static RelationalTypeMapping GetMapping(Type clrType, string storeType)
7878
=> Mapper.FindMapping(clrType, storeType);

test/EFCore.PG.NodaTime.FunctionalTests/NpgsqlNodaTimeTypeMappingTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ public void GenerateCodeLiteral_returns_Duration_literal()
602602

603603
private static RelationalTypeMapping GetMapping(string storeType) => Mapper.FindMapping(storeType);
604604

605-
private static RelationalTypeMapping GetMapping(Type clrType) => (RelationalTypeMapping)Mapper.FindMapping(clrType);
605+
private static RelationalTypeMapping GetMapping(Type clrType) => Mapper.FindMapping(clrType);
606606

607607
private static RelationalTypeMapping GetMapping(Type clrType, string storeType)
608608
=> Mapper.FindMapping(clrType, storeType);

test/EFCore.PG.Tests/Storage/LegacyNpgsqlTypeMappingTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void GenerateSqlLiteral_returns_timestamptz_datetime_literal()
5252

5353
private static RelationalTypeMapping GetMapping(string storeType) => Mapper.FindMapping(storeType);
5454

55-
private static RelationalTypeMapping GetMapping(Type clrType) => (RelationalTypeMapping)Mapper.FindMapping(clrType);
55+
private static RelationalTypeMapping GetMapping(Type clrType) => Mapper.FindMapping(clrType);
5656

5757
public class LegacyNpgsqlTypeMappingFixture : IDisposable
5858
{

test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ private static RelationalTypeMapping GetMapping(string storeType)
905905
=> Mapper.FindMapping(storeType);
906906

907907
private static RelationalTypeMapping GetMapping(Type clrType)
908-
=> (RelationalTypeMapping)Mapper.FindMapping(clrType);
908+
=> Mapper.FindMapping(clrType);
909909

910910
private static RelationalTypeMapping GetMapping(Type clrType, string storeType)
911911
=> Mapper.FindMapping(clrType, storeType);

0 commit comments

Comments
 (0)