Esempio n. 1
0
        internal void Add(RdbColumn column)
        {
            if (column.Info.IsIdentity)
            {
                if (_identityColumn != null)
                {
                    throw new ORMException(string.Format(
                                               "cannot add idenity column {0} to table {1}, it already has an identity column {2}",
                                               column.Name, this.Name, _identityColumn.Name));
                }
                _identityColumn = column;
            }

            if (column.Info.IsPrimaryKey)
            {
                if (_pkColumn != null)
                {
                    throw new ORMException(string.Format(
                                               "cannot add primary key column {0} to table {1}, it already has an primary key column {2}",
                                               column.Name, this.Name, _pkColumn.Name));
                }

                _pkColumn = column;
            }

            if (column.IsLOB)
            {
                _hasLOB = true;
            }

            _columns.Add(column);
        }
Esempio n. 2
0
        /// <summary>
        /// 把属性名转换为列名
        /// </summary>
        /// <param name="propertyName"></param>
        /// <returns></returns>
        internal string Translate(string propertyName)
        {
            string name = null;

            RdbColumn column = FindByPropertyName(propertyName);
            if (column != null) { name = column.Name; }

            if (string.IsNullOrEmpty(name))
            {
                throw new ORMException(string.Format("表 {1} 中没有找到对应的列:{0}。", propertyName, this.Name));
            }

            return name;
        }
Esempio n. 3
0
        internal void Add(RdbColumn column)
        {
            if (column.Info.IsIdentity)
            {
                if (_identityColumn != null)
                {
                    throw new ORMException(string.Format(
                        "cannot add idenity column {0} to table {1}, it already has an identity column {2}",
                        column.Name, this.Name, _identityColumn.Name));
                }
                _identityColumn = column;
            }

            if (column.Info.IsPrimaryKey)
            {
                if (_pkColumn != null)
                {
                    throw new ORMException(string.Format(
                        "cannot add primary key column {0} to table {1}, it already has an primary key column {2}",
                        column.Name, this.Name, _pkColumn.Name));
                }

                _pkColumn = column;
            }

            if (column.IsLOB)
            {
                _hasLOB = true;
            }

            _columns.Add(column);
        }
Esempio n. 4
0
 protected virtual bool CanInsert(RdbColumn column)
 {
     //Sql Server 中的 Identity 列是不需要插入的。
     return(!column.Info.IsIdentity);
 }
Esempio n. 5
0
 protected virtual bool CanInsert(RdbColumn column)
 {
     //Sql Server 中的 Identity 列是不需要插入的。
     return !column.Info.IsIdentity;
 }