Esempio n. 1
0
 /// <summary>
 /// 删除数据实体集合
 /// </summary>
 /// <param name="entities">数据实体集合</param>
 /// <param name="saveChange">是否执行删除</param>
 /// <returns></returns>
 public virtual int Delete(IEnumerable <TEntity> entities, bool saveChange = true)
 {
     ArgumentUtil.ThrowIfNull(entities, nameof(entities));
     //
     WorkContext.RegisterDeleted(entities);
     return(saveChange ? WorkContext.Commit() : 0);
 }
Esempio n. 2
0
 /// <summary>
 /// 删除单个数据实体
 /// </summary>
 /// <param name="entity">数据实体</param>
 /// <param name="saveChange">是否执行删除</param>
 /// <returns></returns>
 public virtual int Delete(TEntity entity, bool saveChange = true)
 {
     ArgumentUtil.ThrowIfNull(entity, nameof(entity));
     //
     WorkContext.RegisterDeleted(entity);
     return(saveChange ? WorkContext.Commit() : 0);
 }
Esempio n. 3
0
        /// <summary>
        /// 根据主键删除单个数据实体
        /// </summary>
        /// <typeparam name="TKey">主键类型</typeparam>
        /// <param name="key">主键值</param>
        /// <param name="saveChange">是否执行删除</param>
        /// <returns></returns>
        public virtual int DeleteById <TKey>(TKey key, bool saveChange = true)
        {
            ArgumentUtil.Validate(key != null, nameof(key));
            //
            var entity = GetById(key);

            if (entity == null)
            {
                return(0);
            }
            //
            return(Delete(entity, saveChange));
        }
Esempio n. 4
0
        public static void Main(string[] args)
        {
            int status = 0;

            try
            {
                Hashtable a = ArgumentUtil.getArguments(args);

                string command = (string)a["command"];

                if (command == null)
                {
                    CommandController.command_help();
                    status = 1;
                }
                else if (command.Equals("send", StringComparison.InvariantCultureIgnoreCase))
                {
                    status = CommandController.command_send(a);
                }
                else if (command.Equals("check_level", StringComparison.InvariantCultureIgnoreCase))
                {
                    status = CommandController.command_check_level(a);
                }
                else if (command.Equals("get_log", StringComparison.InvariantCultureIgnoreCase))
                {
                    status = CommandController.command_get_log(a);
                }
                else
                {
                    CommandController.command_help();
                    status = 1;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                status = 1;
            }

            Environment.Exit(status);
        }
Esempio n. 5
0
 /// <summary>
 /// 根据主键获取单个数据实体
 /// </summary>
 /// <typeparam name="TKey">主键类型</typeparam>
 /// <param name="key">主键值</param>
 /// <returns></returns>
 public virtual TEntity GetById <TKey>(TKey key)
 {
     ArgumentUtil.Validate(key != null, nameof(key));
     //
     return(WorkContext.Set <TEntity>().Find(key));
 }