/// <summary>Convert to.</summary>
        /// <typeparam name="T">Generic type parameter.</typeparam>
        /// <param name="dataReader">The data reader.</param>
        /// <returns>to converted.</returns>
        private static T ConvertTo <T>(IDataReader dataReader)
        {
            var fieldDefs = ModelDefinition <T> .Definition.AllFieldDefinitionsArray;

            using (dataReader)
            {
                if (dataReader.Read())
                {
                    var row = OrmLiteUtilExtensions.CreateInstance <T>();

                    var namingStrategy = OrmLiteConfig.DialectProvider.NamingStrategy;

                    for (int i = 0; i < dataReader.FieldCount; i++)
                    {
                        var fieldDef = fieldDefs.FirstOrDefault(
                            x =>
                            namingStrategy.GetColumnName(x.FieldName).ToUpper() ==
                            dataReader.GetName(i).ToUpper());

                        if (fieldDef == null)
                        {
                            continue;
                        }
                        var value = dataReader.GetValue(i);
                        fieldDef.SetValue(row, value);
                    }

                    return(row);
                }
                return(default(T));
            }
        }
        /// <summary>Converts this object to a SQL in string.</summary>
        /// <returns>This object as a string.</returns>
        public string ToSqlInString()
        {
            if (Count == 0)
            {
                return("NULL");
            }

            return(OrmLiteUtilExtensions.SqlJoin(values));
        }
        /// <summary>Converts a dataReader to a list.</summary>
        /// <typeparam name="T">Generic type parameter.</typeparam>
        /// <param name="dataReader">The data reader.</param>
        /// <returns>The given data converted to a list.</returns>
        private static List <T> ConvertToList <T>(IDataReader dataReader)
        {
            var fieldDefs     = ModelDefinition <T> .Definition.AllFieldDefinitionsArray;
            var fieldDefCache = new Dictionary <int, FieldDefinition>();

            var to = new List <T>();

            using (dataReader)
            {
                while (dataReader.Read())
                {
                    var row = OrmLiteUtilExtensions.CreateInstance <T>();

                    var namingStrategy = OrmLiteConfig.DialectProvider.NamingStrategy;

                    for (int i = 0; i < dataReader.FieldCount; i++)
                    {
                        FieldDefinition fieldDef;
                        if (!fieldDefCache.TryGetValue(i, out fieldDef))
                        {
                            fieldDef = fieldDefs.FirstOrDefault(
                                x =>
                                namingStrategy.GetColumnName(x.FieldName).ToUpper() ==
                                dataReader.GetName(i).ToUpper());
                            fieldDefCache[i] = fieldDef;
                        }

                        if (fieldDef == null)
                        {
                            continue;
                        }

                        var value = dataReader.GetValue(i);
                        fieldDef.SetValue(row, value);
                    }
                    to.Add(row);
                }
            }
            return(to);
        }