Пример #1
0
        public void NullSafeSet(IDbCommand cmd, object value, int index)
        {
            string cmdText = cmd.CommandText;
            int    s       = cmdText.IndexOf(DbFunc + '(');

            if (s < 0)
            {
                if (cmdText.StartsWith("INSERT"))
                {
                    cmdText = cmdText.Replace(", ROWID", "");
                    cmdText = cmdText.Replace(
                        string.Format(":p{0}, :p{1}", index, index + 1),
                        string.Format("{0}(:p{1}, :p{2})", DbFunc, index, index + 1));
                }
                else                 //update
                {
                    cmdText = cmdText.Replace(
                        string.Format(":p{0}, ROWID = :p{1}", index, index + 1),
                        string.Format("{0}(:p{1}, :p{2})", DbFunc, index, index + 1));
                }
                cmd.CommandText = cmdText;
            }

            if (value == null)
            {
                ((IDataParameter)cmd.Parameters[index]).Value     = DBNull.Value;
                ((IDataParameter)cmd.Parameters[index + 1]).Value = DBNull.Value;
            }
            else
            {
                BFileType bf = value as BFileType;
                ((IDataParameter)cmd.Parameters[index]).Value     = bf.DirName;
                ((IDataParameter)cmd.Parameters[index + 1]).Value = bf.FileName;
            }
        }
Пример #2
0
 public object NullSafeGet(IDataReader rs, string[] names, object owner)
 {
     byte[] bin = (byte[])NHibernateUtil.BinaryBlob.NullSafeGet(rs, names[0]);
     if (bin != null)
     {
         BFileType bf = new BFileType();
         bf.Binary = bin;
         return(bf);
     }
     return(null);
 }
Пример #3
0
        public object DeepCopy(object value)
        {
            if (value == null)
            {
                return(null);
            }

            BFileType valueBFile = (BFileType)value;

            return(new BFileType(
                       valueBFile.DirName,
                       valueBFile.FileName,
                       valueBFile.Binary));
        }
Пример #4
0
 public object NullSafeGet(IDataReader rs, string[] names, object owner)
 {
     byte[] bin = (byte[]) NHibernateUtil.BinaryBlob.NullSafeGet(rs, names[0]);
     if (bin != null)
     {
         BFileType bf = new BFileType();
         bf.Binary = bin;
         return bf;
     }
     return null;
 }