Skip to content

Commit

Permalink
use count to check for existence (#4561)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Feb 24, 2025
1 parent fd0b6b2 commit 6a25ecd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Source/Csla/Configuration/ConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static IServiceCollection AddCsla(this IServiceCollection services, Actio
cslaOptions.AddRequiredDataPortalServices(services);

// Default to using LocalProxy and local data portal
var proxyInit = services.Count(i => i.ServiceType.Equals(typeof(IDataPortalProxy))) > 0;
var proxyInit = services.Any(i => i.ServiceType == typeof(IDataPortalProxy));
if (!proxyInit)
{
cslaOptions.DataPortal(options => options.DataPortalClientOptions.UseLocalProxy());
Expand Down
8 changes: 4 additions & 4 deletions Source/Csla/Core/GraphMerger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ private void MergeGraph(IEditableCollection target, IEditableCollection source)

// add items not in target
foreach (var item in source)
if (target.Count(_ => _.Identity == item.Identity) == 0)
if (!target.Any(_ => _.Identity == item.Identity))
target.Add(item);

// remove items not in source
Expand Down Expand Up @@ -206,7 +206,7 @@ private void MergeGraph(IEditableCollection target, IEditableCollection source)

// add items not in target
foreach (var item in source)
if (target.Count(_ => _.Identity == item.Identity) == 0)
if (!target.Any(_ => _.Identity == item.Identity))
target.Add(item);

// remove items not in source
Expand Down Expand Up @@ -354,7 +354,7 @@ private async Task MergeGraphAsync(IEditableCollection target, IEditableCollecti

// add items not in target
foreach (var item in source)
if (target.Count(_ => _.Identity == item.Identity) == 0)
if (!target.Any(_ => _.Identity == item.Identity))
target.Add(item);

// remove items not in source
Expand Down Expand Up @@ -388,7 +388,7 @@ private async Task MergeGraphAsync(IEditableCollection target, IEditableCollecti

// add items not in target
foreach (var item in source)
if (target.Count(_ => _.Identity == item.Identity) == 0)
if (!target.Any(_ => _.Identity == item.Identity))
target.Add(item);

// remove items not in source
Expand Down
2 changes: 1 addition & 1 deletion Source/Csla/DataPortalT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ internal static class Extensions
{
internal static bool RunLocal(this System.Reflection.MethodInfo t)
{
return t.CustomAttributes.Count(a => a.AttributeType.Equals(typeof(RunLocalAttribute))) > 0;
return t.CustomAttributes.Any(a => a.AttributeType == typeof(RunLocalAttribute));
}
}
}

0 comments on commit 6a25ecd

Please sign in to comment.