コード例 #1
0
        public T Add(T item)
        {
            try
            {
                using (var context = new WebPresenceEntities())
                {
                    context.Entry(item).State = EntityState.Added;

                    context.SaveChanges();

                    return(item);
                }
            }
            catch (Exception ex)
            {
                LogManager.Instance.Log(string.Format(DataMesages.DataError, ex.Message, typeof(T).FullName), ex, LoggingLevel.Error);

                return(null);
            }
        }
コード例 #2
0
        public bool Update(params T[] items)
        {
            try
            {
                using (var context = new WebPresenceEntities())
                {
                    foreach (T item in items)
                    {
                        context.Entry(item).State = EntityState.Modified;
                    }

                    context.SaveChanges();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogManager.Instance.Log(string.Format(DataMesages.DataError, ex.Message, typeof(T).FullName), ex, LoggingLevel.Error);

                return(false);
            }
        }