From b48561fc78bd98169ed5a69ebb6dd492e3eb79d9 Mon Sep 17 00:00:00 2001 From: Henk Mollema Date: Fri, 19 Oct 2018 16:58:39 +0200 Subject: [PATCH] Add ResolveKeyProperty extension methods for backwards compat --- .../DommelMapper.IKeyPropertyResolver.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/Dommel/DommelMapper.IKeyPropertyResolver.cs b/src/Dommel/DommelMapper.IKeyPropertyResolver.cs index 3818383c..bedc08a8 100644 --- a/src/Dommel/DommelMapper.IKeyPropertyResolver.cs +++ b/src/Dommel/DommelMapper.IKeyPropertyResolver.cs @@ -1,5 +1,7 @@ using System; +using System.Linq; using System.Reflection; +using static Dommel.DommelMapper; namespace Dommel { @@ -27,4 +29,29 @@ public interface IKeyPropertyResolver PropertyInfo[] ResolveKeyProperties(Type type, out bool isIdentity); } } + + /// + /// Extensions for . + /// + public static class KeyPropertyResolverExtensions + { + /// + /// Resolves the single key property for the specified type. + /// + /// The . + /// The type to resolve the key property for. + /// A instance of the key property of . + public static PropertyInfo ResolveKeyProperty(this IKeyPropertyResolver keyPropertyResolver, Type type) + => keyPropertyResolver.ResolveKeyProperties(type).FirstOrDefault(); + + /// + /// Resolves the single key property for the specified type. + /// + /// The . + /// The type to resolve the key property for. + /// Indicates whether the key properties are identity properties. + /// A instance of the key property of . + public static PropertyInfo ResolveKeyProperty(this IKeyPropertyResolver keyPropertyResolver, Type type, out bool isIdentity) => + keyPropertyResolver.ResolveKeyProperties(type, out isIdentity).FirstOrDefault(); + } }