Example #1
0
 void NHibernate.UserTypes.IUserType.NullSafeSet(
     System.Data.Common.DbCommand cmd,
     object value,
     int index,
     NHibernate.Engine.ISessionImplementor session
     )
 => cmd.Parameters[index].Value = value != null ? value: System.DBNull.Value;
Example #2
0
 public object Generate(NHibernate.Engine.ISessionImplementor session, object obj)
 {
     // can operate more handy with "obj", when all entities will be inherited from
     // common base class
     // todo: ?implement somewhere const for "Entities" string?
     return(PKGenDao.GetNextPK("Entities"));
 }
Example #3
0
        public void NullSafeSet(IDbCommand cmd, object value, int index, bool[] settable,
                                NHibernate.Engine.ISessionImplementor session)
        {
            Vector3 vector = (Vector3)value;

            ((IDataParameter)cmd.Parameters[index]).Value     = vector.X;
            ((IDataParameter)cmd.Parameters[index + 1]).Value = vector.Y;
            ((IDataParameter)cmd.Parameters[index + 2]).Value = vector.Z;
        }
Example #4
0
 object NHibernate.UserTypes.IUserType.NullSafeGet(
     System.Data.Common.DbDataReader rs, string[] names,
     NHibernate.Engine.ISessionImplementor session,
     object owner
     )
 =>
 names.Length != 1 ?
 throw new System.InvalidOperationException("Only expecting one column...")
     : rs[names[0]] is System.DateTime value ?
        public object Generate(NHibernate.Engine.ISessionImplementor session, object obj)
        {
            object id = session.GetEntityPersister(entityName, obj).GetIdentifier(obj, session.EntityMode);

            if (id == null)
            {
                id = Guid.NewGuid().ToString();
            }
            return(id);
        }
Example #6
0
        public object NullSafeGet(System.Data.IDataReader dr, string[] names, NHibernate.Engine.ISessionImplementor session, object owner)
        {
            Double x = (Double)NHibernateUtil.Double.NullSafeGet(dr, names[0], session, owner);
            Double y = (Double)NHibernateUtil.Double.NullSafeGet(dr, names[1], session, owner);
            Double z = (Double)NHibernateUtil.Double.NullSafeGet(dr, names[2], session, owner);

            if (x == null || y == null || z == null)
            {
                return(null);
            }
            return(new Point(x, y, z));
        }
Example #7
0
        public object NullSafeGet(IDataReader dr, string[] names,
                                  NHibernate.Engine.ISessionImplementor session, object owner)
        {
            object obj0 = NHibernateUtil.Double.NullSafeGet(dr, names[0]);
            object obj1 = NHibernateUtil.String.NullSafeGet(dr, names[1]);

            if (obj0 == null || obj1 == null)
            {
                return(null);
            }
            double value    = (double)obj0;
            string currency = (string)obj1;

            return(new MonetaryAmount(value, currency));
        }
Example #8
0
 public void NullSafeSet(IDbCommand cmd, object obj, int index,
                         NHibernate.Engine.ISessionImplementor session)
 {
     if (obj == null)
     {
         ((IDataParameter)cmd.Parameters[index]).Value     = DBNull.Value;
         ((IDataParameter)cmd.Parameters[index + 1]).Value = DBNull.Value;
     }
     else
     {
         MonetaryAmount amount = (MonetaryAmount)obj;
         ((IDataParameter)cmd.Parameters[index]).Value     = amount.Value;
         ((IDataParameter)cmd.Parameters[index + 1]).Value = amount.Currency;
     }
 }
Example #9
0
        public object NullSafeGet(IDataReader dr, string[] names, NHibernate.Engine.ISessionImplementor session, object owner)
        {
            var value = dr[names[0]];

            if (value == DBNull.Value)
            {
                return(new ContentRelation());
            }

            var id = (int)value;

            return(new ContentRelation
            {
                ForeignID = id,
                ValueAccessor = () => ((ISession)session).Get <ContentItem>(id)
            });
        }
Example #10
0
        public object NullSafeGet(IDataReader rs, string[] names, NHibernate.Engine.ISessionImplementor session,
                                  object owner)
        {
            object vector = null;

            int x = rs.GetOrdinal(names[0]);
            int y = rs.GetOrdinal(names[1]);
            int z = rs.GetOrdinal(names[2]);

            if (!rs.IsDBNull(x) && !rs.IsDBNull(y) && !rs.IsDBNull(z))
            {
                float X = (Single)Convert.ToDouble(rs[x].ToString());
                float Y = (Single)Convert.ToDouble(rs[y].ToString());
                float Z = (Single)Convert.ToDouble(rs[z].ToString());
                vector = new Vector3(X, Y, Z);
            }
            return(vector);
        }
Example #11
0
 public object Replace(object original, object target, NHibernate.Engine.ISessionImplementor session,
                       object owner)
 {
     return(original);
 }
 public override NHibernate.Collection.IPersistentCollection Instantiate(NHibernate.Engine.ISessionImplementor session, NHibernate.Persister.Collection.ICollectionPersister persister)
 {
     return(new PersistentDetailCollectionList(session));
 }
Example #13
0
 object ILazyInitializer.GetImplementation(NHibernate.Engine.ISessionImplementor s)
 {
     return(wrapped);
 }
Example #14
0
    object IUserCollectionType.ReplaceElements(object original, object target, NHibernate.Persister.Collection.ICollectionPersister cp, object owner, System.Collections.IDictionary copyCache, NHibernate.Engine.ISessionImplementor session)
    {
        IDictionary <string, T> result = (IDictionary <string, T>)target;

        result.Clear();
        IEnumerable <KeyValuePair <string, T> > iter = (IDictionary <string, T>)original;

        foreach (KeyValuePair <string, T> me in iter)
        {
            string key   = (string)cp.IndexType.Replace(me.Key, null, session, owner, copyCache);
            T      value = (T)cp.ElementType.Replace(me.Value, null, session, owner, copyCache);
            result[key] = value;
        }
        var originalPc = original as IPersistentCollection;
        var resultPc   = result as IPersistentCollection;

        if (originalPc != null && resultPc != null)
        {
            if (!originalPc.IsDirty)
            {
                resultPc.ClearDirty();
            }
        }
        return(result);
    }
Example #15
0
 public void NullSafeSet(IDbCommand cmd, object value, int index, bool[] settable, NHibernate.Engine.ISessionImplementor session)
 {
     NHibernateUtil.Int32.NullSafeSet(cmd, (value == null) ? (object)null : ((ContentRelation)value).ForeignID, index);
     //if(value == null)
     //    cmd.Parameters[index] = DBNull.Value;
     //else
     //    cmd.Parameters[index] = ((ContentRelation)value).ForeignID;
 }
Example #16
0
 public PersistentDetailCollectionList(NHibernate.Engine.ISessionImplementor session)
     : base(session)
 {
 }
Example #17
0
        public void NullSafeSet(System.Data.IDbCommand cmd, object value, int index, bool[] settable, NHibernate.Engine.ISessionImplementor session)
        {
            Point point = (value == null) ? new Point() : (Point)value;

            if (settable[0])
            {
                NHibernateUtil.Double.NullSafeSet(cmd, point.X, index++, session);
            }
            if (settable[1])
            {
                NHibernateUtil.Double.NullSafeSet(cmd, point.Y, index++, session);
            }
            if (settable[2])
            {
                NHibernateUtil.Double.NullSafeSet(cmd, point.Z, index++, session);
            }
        }
 public object Generate(NHibernate.Engine.ISessionImplementor session, object obj)
 {
     return(null);    //this should be custom implemented
 }
Example #19
0
 public object Assemble(object cached, NHibernate.Engine.ISessionImplementor session, object owner)
 {
     return(cached);
 }
Example #20
0
    public void NullSafeSet(IDbCommand cmd, object value, int index, bool[] settable, NHibernate.Engine.ISessionImplementor session)
    {
        var list = value as IList <TChoice>;

        NHibernateUtil.String.Set(cmd, string.Join(", ", list.Select(choice => choice.Id.ToString()).ToArray()), index);
    }
Example #21
0
 public override IResultSetsCommand GetResultSetsCommand(NHibernate.Engine.ISessionImplementor session)
 {
     return(new BasicResultSetsCommand(session));
 }
 public override NHibernate.Collection.IPersistentCollection Wrap(NHibernate.Engine.ISessionImplementor session, object collection)
 {
     return(new PersistentDetailCollectionList(session, (IList <DetailCollection>)collection));
 }
 public override object Copy(object original, object current, NHibernate.Engine.ISessionImplementor session, object owner, System.Collections.IDictionary copiedAlready)
 {
     return(original);
 }
Example #24
0
    NHibernate.Collection.IPersistentCollection IUserCollectionType.Wrap(NHibernate.Engine.ISessionImplementor session, object collection)
    {
        var dict = new Dictionary <string, T>();

        return(new PersistentGenericMap <string, T>(session, (IDictionary <string, T>)collection));
    }
Example #25
0
 public object Disassemble(object value, NHibernate.Engine.ISessionImplementor session)
 {
     return(value);
 }
Example #26
0
 public object Assemble(object cached, NHibernate.Engine.ISessionImplementor session, object owner)
 {
     throw new NotImplementedException();
 }
Example #27
0
 public object Generate(NHibernate.Engine.ISessionImplementor session, object obj)
 {
     return(GuidCustomId.NewSequentialGuid(SequentialGuidType.SequentialAsString));
 }
Example #28
0
 public object Disassemble(object value, NHibernate.Engine.ISessionImplementor session)
 {
     throw new NotImplementedException();
 }
Example #29
0
 public object Replace(object original, object target, NHibernate.Engine.ISessionImplementor session, object owner)
 {
     throw new NotImplementedException();
 }
Example #30
0
 NHibernate.Collection.IPersistentCollection IUserCollectionType.Instantiate(NHibernate.Engine.ISessionImplementor session, NHibernate.Persister.Collection.ICollectionPersister persister)
 {
     return(new PersistentGenericMap <string, T>(session));
 }