public DictionaryMaterializer(DbCommandBuilder <TCommand, TParameter> commandBuilder, string keyColumn, DictionaryOptions dictionaryOptions) : base(commandBuilder) { m_KeyColumn = commandBuilder.TryGetColumn(keyColumn)?.SqlName ?? keyColumn; m_DictionaryOptions = dictionaryOptions; if (m_DictionaryOptions.HasFlag(DictionaryOptions.InferConstructor)) { Constructor = InferConstructor(); } }
public ImmutableDictionaryMaterializer(DbCommandBuilder <TCommand, TParameter> commandBuilder, string keyColumn, DictionaryOptions dictionaryOptions) : base(commandBuilder) { if (dictionaryOptions.HasFlag(DictionaryOptions.DiscardDuplicates)) { throw new NotImplementedException("DiscardDuplicates is not implemented for ImmutableDictionary with default constructors."); } m_KeyColumn = commandBuilder.TryGetColumn(keyColumn)?.SqlName ?? keyColumn; m_DictionaryOptions = dictionaryOptions; if (m_DictionaryOptions.HasFlag(DictionaryOptions.InferConstructor)) { Constructor = InferConstructor(); } }
public DictionaryMaterializer(DbCommandBuilder <TCommand, TParameter> commandBuilder, string keyColumn, DictionaryOptions dictionaryOptions) : base(commandBuilder) { m_KeyColumn = commandBuilder.TryGetColumn(keyColumn)?.SqlName ?? keyColumn; m_DictionaryOptions = dictionaryOptions; if (m_DictionaryOptions.HasFlag(DictionaryOptions.InferConstructor)) { var constructors = ObjectMetadata.Constructors.Where(x => x.Signature.Length > 0).ToList(); if (constructors.Count == 0) { throw new MappingException($"Type {typeof(TObject).Name} has does not have any non-default constructors."); } if (constructors.Count > 1) { throw new MappingException($"Type {typeof(TObject).Name} has more than one non-default constructor. Please use the WithConstructor method to specify which one to use."); } Constructor = constructors[0]; } }