Пример #1
0
        string GetSqlTypeByMem(MemberInfo info)
        {
            Type   type       = GetTypeByMem(info);
            string stringType = type.ToString();

            if (loadedTypes.ContainsKey(type))
            {
                var h = loadedTypes[type];
                return(GetSqlTypeByMem(h.idInfo.Mem));
            }

            return(conf.GetSqlCon(stringType));
        }
Пример #2
0
        public ViHibSession(ViHibConfiguration c)
        {
            conf = c;

            DbProviderFactory m_factory = DbProviderFactories.GetFactory(conf.providerName);

            m_connection = m_factory.CreateConnection();
            m_connection.ConnectionString = conf.connectionString;
            m_connection.Open();
            m_tranaction = m_connection.BeginTransaction();

            #region Заглавная таблица

            using (var com = m_connection.CreateCommand())
            {
                com.Transaction = m_tranaction;
                try
                {
                    com.CommandText = "select count(1) as c from " + HibTableName;

                    using (var r = com.ExecuteReader())
                    {
                        r.Read();
                        r.Close();
                    }
                }
                catch (Exception)
                {
                    com.CommandText = string.Format(@"CREATE TABLE [{1}](
		[parcode] {0} NOT NULL,
		[parval] {0}  ) 

", conf.GetSqlCon(typeof(string).ToString()), HibTableName);

                    com.ExecuteNonQuery();
                }
            }

            #endregion
        }