Beispiel #1
0
        /// <summary>更新</summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public virtual Int32 Update(IEntity entity)
        {
            var ds = entity.Dirtys;

            // 没有脏数据,不需要更新
            if (ds.Count == 0)
            {
                return(0);
            }

            DbParameter[] dps = null;
            var           sql = SQL(entity, DataObjectMethodType.Update, ref dps);

            if (String.IsNullOrEmpty(sql))
            {
                return(0);
            }

            var op      = EntityFactory.CreateOperate(entity.GetType());
            var session = op.Session;
            //Int32 rs = dps != null && dps.Length > 0 ? session.Execute(sql, CommandType.Text, dps) : session.Execute(sql);
            Int32 rs = dps != null && dps.Length > 0 ? session.Execute(false, true, sql, CommandType.Text, dps) : session.Execute(false, true, sql);

            //清除脏数据,避免重复提交
            ds.Clear();

            //entity.ClearAdditionalValues();
            EntityAddition.ClearValues(entity as EntityBase);

            return(rs);
        }
Beispiel #2
0
        static Boolean CheckAdditionalValue(StringBuilder sb, IEntity entity, String name, String cname)
        {
            if (!EntityAddition.TryGetValue(entity as EntityBase, name, out var addvalue, out var sign)) return false;

            if (sign)
                sb.AppendFormat("{0}+{1}", cname, addvalue);
            else
                sb.AppendFormat("{0}-{1}", cname, addvalue);

            return true;
        }
Beispiel #3
0
        static Boolean CheckAdditionalValue(StringBuilder sb, IEntity entity, String name, String cname)
        {
            Object  addvalue = null;
            Boolean sign;

            if (!EntityAddition.TryGetValue(entity as EntityBase, name, out addvalue, out sign))
            {
                return(false);
            }

            if (sign)
            {
                sb.AppendFormat("{0}+{1}", cname, addvalue);
            }
            else
            {
                sb.AppendFormat("{0}-{1}", cname, addvalue);
            }

            return(true);
        }
Beispiel #4
0
        /// <summary>更新</summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public virtual Int32 Update(IEntity entity)
        {
            var ds = entity.Dirtys;
            // 没有脏数据,不需要更新
            if (ds.Count == 0) return 0;

            IDataParameter[] dps = null;
            var sql = SQL(entity, DataObjectMethodType.Update, ref dps);
            if (String.IsNullOrEmpty(sql)) return 0;

            var op = EntityFactory.CreateOperate(entity.GetType());
            var session = op.Session;
            var rs = session.Execute(sql, CommandType.Text, dps);

            //清除脏数据,避免重复提交
            ds.Clear();

            EntityAddition.ClearValues(entity as EntityBase);

            return rs;
        }