// GET api/professions
        public Object Get(ProfessionQuery query)
        {
            string msg;
            try
            {
                if (query == null)
                    query = new ProfessionQuery();
                List<Profession> dbList = BusinessService.GetProfessionListByQuery(query);
                //List<UserAPIModel> vmList = UserAPIModel.FromUserList(dbList);

                msg = string.Format(Intern4jobResources.MSG_SINGLE_ACTION_SUCCESS, "获取", "专业列表");
                return new { IsSuccess = true, Message = msg, Obj = dbList };
            }
            catch (Exception e)
            {
                msg = string.Format(Intern4jobResources.MSG_SINGLE_ACTION_FAIL, "获取", "专业列表") + string.Format(Intern4jobResources.STR_FAIL_RESAON, ExceptionHelper.GetInnerExceptionInfo(e));
                return new { IsSuccess = false, Message = msg };
            }
        }
 private static dynamic _orderByKey(Profession obj, ProfessionQuery query)
 {
     if (string.IsNullOrEmpty(query.OrderByKey))
         return obj.Id;
     return obj.GetType().GetProperty(query.OrderByKey).GetValue(obj);
 }
        public static bool _isMatch(Profession obj, ProfessionQuery query)
        {
            if (!string.IsNullOrEmpty(query.IdEqual) && !string.Equals(obj.Id, query.IdEqual))
                return false;
            if (!string.IsNullOrEmpty(query.IdNotEqual) && string.Equals(obj.Id, query.IdNotEqual))
                return false;

            if (!string.IsNullOrEmpty(query.NameEqual) && !string.Equals(obj.Name, query.NameEqual))
                return false;
            if (!string.IsNullOrEmpty(query.NameNotEqual) && string.Equals(obj.Name, query.NameNotEqual))
                return false;
            if (!string.IsNullOrEmpty(query.NameLike) && !obj.Name.Contains(query.NameLike))
                return false;

            return true;
        }
        public static List<Profession> GetProfessionListByQuery(ProfessionQuery query)
        {
            using (var context = new Intern4jobEntities())
            {
                var repository = new ProfessionRepository(context);

                List<Profession> professions = repository.GetPageList(item => _isMatch(item, query), item => _orderByKey(item, query), query.OrderByValue, query.Offset, query.Limit);
                return professions;
            }
        }
 public static Profession GetProfessionById(string id4query)
 {
     ProfessionQuery query = new ProfessionQuery() { IdEqual = id4query };
     Profession objInDb = GetProfessionListByQuery(query).FirstOrDefault();
     return objInDb;
 }