Exemplo n.º 1
0
        void AddToDictionary(TDictionary result, StreamingObjectConstructor <TObject> source)
        {
            if (m_KeyFunction != null)
            {
                if (m_DictionaryOptions.HasFlag(DictionaryOptions.DiscardDuplicates))
                {
                    result[m_KeyFunction(source.Current)] = source.Current;
                }
                else
                {
                    result.Add(m_KeyFunction(source.Current), source.Current);
                }
            }
            else
            {
                if (!source.CurrentDictionary.ContainsKey(m_KeyColumn))
                {
                    throw new MappingException("The result set does not contain a column named " + m_KeyColumn);
                }

                if (m_DictionaryOptions.HasFlag(DictionaryOptions.DiscardDuplicates))
                {
                    result[(TKey)source.CurrentDictionary[m_KeyColumn]] = source.Current;
                }
                else
                {
                    result.Add((TKey)source.CurrentDictionary[m_KeyColumn], source.Current);
                }
            }
        }
Exemplo n.º 2
0
        void AddToDictionary(TDictionary result, StreamingObjectConstructor <TObject> source, TObject value)
        {
            if (m_KeyFunction != null)
            {
                if (m_DictionaryOptions.HasFlag(DictionaryOptions.DiscardDuplicates))
                {
                    result[m_KeyFunction(value)] = value;
                }
                else
                {
                    result.Add(m_KeyFunction(value), value);
                }
            }
            else if (m_KeyColumn != null)
            {
                if (!source.CurrentDictionary.ContainsKey(m_KeyColumn))
                {
                    throw new MappingException("The result set does not contain a column named " + m_KeyColumn);
                }

                var key = source.CurrentDictionary[m_KeyColumn];
                if (key == null)
                {
                    throw new MissingDataException("Key column is null");
                }

                if (m_DictionaryOptions.HasFlag(DictionaryOptions.DiscardDuplicates))
                {
                    result[(TKey)key] = value;
                }
                else
                {
                    result.Add((TKey)key, value);
                }
            }
        }
Exemplo n.º 3
0
 public StreamingObjectConstructorDictionary(StreamingObjectConstructor <T> parent)
 {
     m_Parent = parent;
 }