Ejemplo n.º 1
0
        /// <summary>
        /// For a given type, return the closest-match SQLite TypeAffinity, which only understands a very limited subset of types.
        /// </summary>
        /// <param name="typ">The type to evaluate</param>
        /// <returns>The SQLite type affinity for that type.</returns>
        internal static TypeAffinity TypeToAffinity(Type typ)
        {
            var tc = NetTypes.GetNetType(typ);

            if (tc == NetType.Object)
            {
                if (typ == typeof(byte[]) || typ == typeof(Guid))
                {
                    return(TypeAffinity.Blob);
                }
                else
                {
                    return(TypeAffinity.Text);
                }
            }
            return(_typecodeAffinities[(int)tc]);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// For a given intrinsic type, return a DbType
        /// </summary>
        /// <param name="typ">The native type to convert</param>
        /// <returns>The corresponding (closest match) DbType</returns>
        internal static DbType TypeToDbType(Type typ)
        {
            var tc = NetTypes.GetNetType(typ);

            if (tc == NetType.Object)
            {
                if (typ == typeof(byte[]))
                {
                    return(DbType.Binary);
                }
                if (typ == typeof(Guid))
                {
                    return(DbType.Guid);
                }
                return(DbType.String);
            }
            return(_typetodbtype[(int)tc]);
        }