/// <summary>
        /// 根据ID删除记录
        /// </summary>
        /// <param name="id">要删除的记录ID</param>
        /// <returns></returns>
        public int DeleteById(object id)
        {
            int ret = -1;

            DeleteCondition con = new DeleteCondition(EntityInfo.DBInfo);

            con.Tables.Append(EntityInfo.DBInfo.CurrentDbAdapter.FormatTableName(EntityInfo.TableName));
            ParamList list = new ParamList();

            ScopeList      lstScope = new ScopeList();
            PrimaryKeyInfo pkInfo   = id as PrimaryKeyInfo;

            if (pkInfo == null)
            {
                lstScope.AddEqual(EntityInfo.PrimaryProperty[0].PropertyName, id);
            }
            else
            {
                pkInfo.FillScope(EntityInfo.PrimaryProperty, lstScope, true);
            }
            con.Condition.Append("1=1");
            con.Condition.Append(DataAccessCommon.FillCondition(EntityInfo, list, lstScope));
            Dictionary <string, bool> cacheTables = null;

            cacheTables = _oper.DBInfo.QueryCache.CreateMap(EntityInfo.TableName);

            ret = ExecuteCommand(con.GetSql(true), list, CommandType.Text, cacheTables);
            return(ret);
        }
Example #2
0
        public void Delete(DeleteCondition deleteCondition)
        {
            List <Assignment> assignments = GetList();

            for (int i = 0; i < assignments.Count; i++)
            {
                if (deleteCondition(assignments[i]))
                {
                    assignments.RemoveAt(i);
                }
            }
            SaveAll(assignments);
        }
Example #3
0
        public HttpResponseMessage Delete(DeleteCondition dc)
        {
            DELETEDal.DeleteCondition dddc = new DELETEDal.DeleteCondition();

            dddc.index = dc.index;
            dddc.type = dc.type;
            dddc.id = dc.id;
            bool results = false;
            if (dc.sign.Equals("confirm"))
            {
                results = _dal.DELETE(dddc);
            }
            string str = results.ToString();
            HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json") };
            return result;
        }
        /// <summary>
        /// 删除指定数据
        /// </summary>
        /// <param name="obj">要删除的实体</param>
        /// <param name="scopeList">要删除的条件</param>
        /// <param name="isConcurrency">是否版本并发删除</param>
        /// <returns></returns>
        public int Delete(EntityBase obj, ScopeList scopeList, bool isConcurrency)
        {
            DeleteCondition con = new DeleteCondition(EntityInfo.DBInfo);

            con.Tables.Append(EntityInfo.DBInfo.CurrentDbAdapter.FormatTableName(EntityInfo.TableName));
            ParamList list = new ParamList();
            Type      type = EntityInfo.EntityType;

            con.Condition.Append("1=1");

            if (obj != null)
            {
                if (scopeList == null)//通过ID删除
                {
                    scopeList = new ScopeList();
                    foreach (EntityPropertyInfo info in EntityInfo.PrimaryProperty)
                    {
                        scopeList.AddEqual(info.PropertyName, info.GetValue(obj));
                    }
                }
            }
            con.Condition.Append(DataAccessCommon.FillCondition(EntityInfo, list, scopeList));


            if (isConcurrency)
            {
                int index = 0;
                foreach (EntityPropertyInfo pInfo in EntityInfo.PropertyInfo)
                {
                    if (pInfo.IsVersion)
                    {
                        FillWhereConcurrency(con.Condition, pInfo, list, pInfo.GetValue(obj), ref index);
                    }
                }
            }
            Dictionary <string, bool> cacheTables = null;

            cacheTables = _oper.DBInfo.QueryCache.CreateMap(EntityInfo.TableName);

            int ret = -1;

            ret = ExecuteCommand(con.GetSql(true), list, CommandType.Text, cacheTables);

            return(ret);
        }
Example #5
0
 public bool DELETE(DeleteCondition dc)
 {
     return ESHelper.Delete(dc.index,dc.type,dc.id);
 }