Exemplo n.º 1
0
        public OptResult DeleteBatch(IList <string> ids)
        {
            OptResult rst = null;

            if (ids.IsEmpty())
            {
                rst = OptResult.Build(ResultCode.ParamError, string.Format("{0},参数不能为空!", Msg_BatchDeleteField));
                return(rst);
            }
            //1、是否有不存在的数据
            var where = Predicates.Field <Field>(f => f.id, Operator.Eq, ids);
            var count = _fieldRep.Count(where);

            if (count != ids.Count)
            {
                rst = OptResult.Build(ResultCode.DataNotFound, Msg_BatchDeleteField);
                return(rst);
            }
            //2、删
            try
            {
                bool val = _fieldRep.Delete(where);
                rst = OptResult.Build(val ? ResultCode.Success : ResultCode.Fail, Msg_BatchDeleteField);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(Msg_BatchDeleteField, ex);
                rst = OptResult.Build(ResultCode.DbError, Msg_BatchDeleteField);
            }
            return(rst);
        }
Exemplo n.º 2
0
        private bool HasFields(IEnumerable <string> tbIds)
        {
            if (tbIds.IsEmpty())
            {
                return(false);
            }

            var count = _fieldRep.Count(Predicates.Field <Field>(f => f.tbid, Operator.Eq, tbIds));

            return(count > 0);
        }