refactor(linq): extract GetEmptyQueryable<T> helper for empty-return paths
SonarQube Analysis / sonarqube (pull_request) Successful in 3m28s
SonarQube Analysis / sonarqube (pull_request) Successful in 3m28s
DRYs the four `Enumerable.Empty<T>().AsQueryable()` returns added in `2c23ba4` (S1168 fix) into a single `public static IQueryable<T> GetEmptyQueryable<T>()` helper on `LinqQueryBreakdown`. No behavior change — all 1180 tests stay green. Co-Authored-By: Thom Lamb <thomlamb@gmail.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using System.Linq.Expressions;
|
||||
using Strata.SqlTools.Breakdowns.SqlServer;
|
||||
using System.Linq.Expressions;
|
||||
using PostgreSqlBreakdown = Strata.SqlTools.Breakdowns.PostgreSql.QueryBreakdown;
|
||||
using SnowflakeBreakdown = Strata.SqlTools.Breakdowns.Snowflake.QueryBreakdown;
|
||||
|
||||
@@ -195,24 +195,32 @@ public class LinqQueryBreakdown : QueryBreakdown
|
||||
{
|
||||
if (OriginalExpression == null)
|
||||
{
|
||||
return Enumerable.Empty<T>().AsQueryable();
|
||||
return GetEmptyQueryable<T>();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (OriginalExpression is Expression && EntityType == typeof(T))
|
||||
{
|
||||
return Enumerable.Empty<T>().AsQueryable();
|
||||
return GetEmptyQueryable<T>();
|
||||
}
|
||||
|
||||
return Enumerable.Empty<T>().AsQueryable();
|
||||
return GetEmptyQueryable<T>();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return Enumerable.Empty<T>().AsQueryable();
|
||||
return GetEmptyQueryable<T>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get and empty queryable of T
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The entity type for the query.</typeparam>
|
||||
/// <returns>An empty IQueryable of the type.</returns>
|
||||
public static IQueryable<T> GetEmptyQueryable<T>() where T : class
|
||||
=> Enumerable.Empty<T>().AsQueryable();
|
||||
|
||||
/// <summary>
|
||||
/// Analyzes an INSERT operation for the given entity.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user