public IHttpActionResult Patch([FromODataUri] string key, Delta <CODE_AREAEntity> patch)
        {
            CODE_AREAService service = new CODE_AREAService();
            object           id;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            else if (patch.GetChangedPropertyNames().Contains("F_AREAID") && patch.TryGetPropertyValue("F_AREAID", out id) && (string)id != key)
            {
                return(BadRequest("The key from the url must match the key of the entity in the body"));
            }

            try
            {
                var query = service.GetEntity(key);
                patch.Patch(query);
                service.UpdateEntity(query);
                return(Updated(query));
            }
            catch (Exception)
            {
                return(NotFound());
            }
        }
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public IHttpActionResult Delete([FromODataUri] string key)
        {
            CODE_AREAService service = new CODE_AREAService();

            try
            {
                service.PhysicalDelRecord(key);
                return(Ok(true));
            }
            catch (Exception)
            {
                return(Ok(false));
            }
        }
        public IHttpActionResult Get(ODataQueryOptions <CODE_AREAEntity> odataQueryOptions)
        {
            Expression <Func <CODE_AREAEntity, bool> > myfilter = null;

            if (odataQueryOptions.Filter != null)
            {
                myfilter = odataQueryOptions.Filter.ToExpression <CODE_AREAEntity>();
            }
            try
            {
                CODE_AREAService service = new CODE_AREAService();
                var expression           = LinqExtensions.True <CODE_AREAEntity>();
                if (myfilter != null)
                {
                    expression = expression.And(myfilter);
                }
                var query = service.IQueryRecord(expression).ToList();
                return(Ok(query.AsQueryable()));
            }
            catch (Exception)
            {
                return(NotFound());
            }
        }
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name="model"></param>
        public void Post(CODE_AREAEntity model)
        {
            CODE_AREAService service = new CODE_AREAService();

            service.SaveEntity(model.F_AREAID, model);
        }
        /// <summary>
        /// 更新数据,幂等
        /// </summary>
        /// <param name="key"></param>
        /// <param name="model"></param>
        public void Put([FromODataUri] string key, CODE_AREAEntity model)
        {
            CODE_AREAService service = new CODE_AREAService();

            service.UpdateEntity(model);
        }