/// <summary> /// Gets the key properties for the specified type, using the configured <see cref="IKeyPropertyResolver"/>. /// </summary> /// <param name="type">The <see cref="Type"/> to get the key properties for.</param> /// <param name="isIdentity">A value indicating whether the keys represent an identity.</param> /// <returns>The key properties for <paramref name="type"/>.</returns> public static PropertyInfo[] KeyProperties(Type type, out bool isIdentity) { if (!_typeKeyPropertiesCache.TryGetValue(type, out var keyPropertyInfo)) { var propertyInfos = _keyPropertyResolver.ResolveKeyProperties(type, out isIdentity); keyPropertyInfo = new KeyPropertyInfo(propertyInfos, isIdentity); _typeKeyPropertiesCache.TryAdd(type, keyPropertyInfo); } isIdentity = keyPropertyInfo.IsIdentity; LogReceived?.Invoke($"Resolved property '{string.Join<PropertyInfo>(", ", keyPropertyInfo.PropertyInfos)}' (Identity: {isIdentity}) as key property for '{type}'"); return(keyPropertyInfo.PropertyInfos); }
/// <summary> /// Gets the key property for the specified type, using the configured <see cref="IKeyPropertyResolver"/>. /// </summary> /// <param name="type">The <see cref="Type"/> to get the key property for.</param> /// <param name="isIdentity">A value indicating whether the key is an identity.</param> /// <returns>The key property for <paramref name="type"/>.</returns> public static PropertyInfo KeyProperty(Type type, out bool isIdentity) { if (!_typeKeyPropertyCache.TryGetValue(type, out var keyProperty)) { var propertyInfo = _keyPropertyResolver.ResolveKeyProperty(type, out isIdentity); keyProperty = new KeyPropertyInfo(propertyInfo, isIdentity); _typeKeyPropertyCache.TryAdd(type, keyProperty); } isIdentity = keyProperty.IsIdentity; LogReceived?.Invoke($"Resolved property '{keyProperty.PropertyInfo}' (Identity: {isIdentity}) as key property for '{type.Name}'"); return(keyProperty.PropertyInfo); }