/// <summary>
        /// 获取下一个数据库主键值
        /// </summary>
        /// <param name="Mapping"></param>
        /// <returns></returns>
        public Hashtable GeneratNextPrimaryKey(Draco.DB.ORM.Mapping.ITableMapping Mapping)
        {
            string TableName = Mapping.TableName;

            if (RequestCount == 0)
            {
                //第一次调用,确认表是否存在
                InitTable(TableName);
            }
            long   value = 1;
            string sql   = "select NextValue from ORM_SEQUENCE where  TableName='" + TableName + "'";
            object o     = m_IDBHandler.ExecuteScalar(sql);
            string uSQL  = "";

            if (o != null && o != DBNull.Value)
            {
                value = Convert.ToInt64(o);
                long next = value + 1;
                uSQL = " update ORM_SEQUENCE set NextValue=" + next + " where TableName='" + TableName + "'";
            }
            else
            {
                uSQL = "insert into ORM_SEQUENCE (TableName,NextValue)values('" + TableName + "',2)";
            }
            //回写下一个值
            m_IDBHandler.ExecuteNonQuery(uSQL);
            RequestCount++;

            Hashtable hash = new Hashtable();

            hash.Add(Mapping.PrimaryKeyCollection[0].PropertyName, value);
            return(hash);
        }
        /// <summary>
        /// 获取下一个主键值
        /// </summary>
        /// <param name="Mapping"></param>
        /// <returns></returns>
        public Hashtable GeneratNextPrimaryKey(Draco.DB.ORM.Mapping.ITableMapping Mapping)
        {
            string    TableName = Mapping.TableName;
            String    keyName   = Mapping.PrimaryKeyCollection[0].ColumnName;
            long      value     = GeneratNextPrimaryKey(TableName, keyName);
            Hashtable hash      = new Hashtable();

            hash.Add(Mapping.PrimaryKeyCollection[0].PropertyName, value);
            return(hash);
        }
Esempio n. 3
0
        /// <summary>
        /// 生成下一个主键
        /// </summary>
        /// <param name="Mapping"></param>
        /// <returns></returns>
        public Hashtable GeneratNextPrimaryKey(Draco.DB.ORM.Mapping.ITableMapping Mapping)
        {
            Hashtable table = new Hashtable();

            foreach (var key in Mapping.PrimaryKeyCollection)
            {
                table.Add(key.PropertyName, Generate());
            }
            return(table);
        }
 /// <summary>
 /// 获取下一主键值
 /// </summary>
 /// <param name="Mapping"></param>
 /// <returns></returns>
 public Hashtable GeneratNextPrimaryKey(Draco.DB.ORM.Mapping.ITableMapping Mapping)
 {
     //返回空的Hashtable,不对主键赋值
     return(new Hashtable());
 }