Beispiel #1
0
        public bool updateERAPermissionForInf(long id, Dictionary <string, object> dicObj)
        {
            bool ret = false;

            using (NaNaEntities db = new NaNaEntities()) {
                ERAPermissionForInf e = db.ERAPermissionForInf.AsQueryable().FirstOrDefault(x => x.Id == id);

                //不存在此資料
                if (e == null)
                {
                    return(false);
                }

                Type cl = e.GetType();

                foreach (var obj in dicObj)
                {
                    if (cl.GetProperty(obj.Key) != null)
                    {
                        cl.GetProperty(obj.Key).SetValue(e, obj.Value);
                    }
                }

                db.SaveChanges();
                ret = true;
            }

            return(ret);
        }