2
2
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
3
4
4
using System ;
5
+ using System . Collections . Concurrent ;
5
6
using System . Collections . Generic ;
6
7
using System . Diagnostics ;
7
8
using System . Linq ;
@@ -23,8 +24,8 @@ public class Model : ConventionalAnnotatable, IMutableModel
23
24
private readonly SortedDictionary < string , EntityType > _entityTypes
24
25
= new SortedDictionary < string , EntityType > ( ) ;
25
26
26
- private readonly Dictionary < Type , string > _clrTypeNameMap
27
- = new Dictionary < Type , string > ( ) ;
27
+ private readonly ConcurrentDictionary < Type , string > _clrTypeNameMap
28
+ = new ConcurrentDictionary < Type , string > ( ) ;
28
29
29
30
private readonly SortedDictionary < string , SortedSet < EntityType > > _entityTypesWithDefiningNavigation
30
31
= new SortedDictionary < string , SortedSet < EntityType > > ( ) ;
@@ -349,15 +350,7 @@ public virtual EntityType AddEntityType(
349
350
/// directly from your code. This API may change or be removed in future releases.
350
351
/// </summary>
351
352
public virtual string GetDisplayName ( Type type )
352
- {
353
- if ( ! _clrTypeNameMap . TryGetValue ( type , out var name ) )
354
- {
355
- name = type . DisplayName ( ) ;
356
- _clrTypeNameMap [ type ] = name ;
357
- }
358
-
359
- return name ;
360
- }
353
+ => _clrTypeNameMap . GetOrAdd ( type , t => t . DisplayName ( ) ) ;
361
354
362
355
/// <summary>
363
356
/// This API supports the Entity Framework Core infrastructure and is not intended to be used
0 commit comments