public IEnumerable <TEntity> FindAll()
        {
            var query = from entity in ObjectContextHolder.ObjectContext().CreateObjectSet <TEntity>()
                        select entity;

            return(query.AsEnumerable());
        }
        public UserAccount FindByAccountId(string accountId)
        {
            var query = from entity in ObjectContextHolder.ObjectContext().UserAccount
                        where entity.AccountId == accountId
                        select entity;

            return(query.SingleOrDefault());
        }
        /// <summary>
        /// 账户情报取得
        /// </summary>
        /// <param name="account">账户名</param>
        /// <returns></returns>
        public UserAccount FindByAccount(string account)
        {
            var query = from entity in ObjectContextHolder.ObjectContext().UserAccount
                        where entity.Account.Equals(account)
                        select entity;

            return(query.FirstOrDefault());
        }
        /// <summary>
        /// CurrentInfoHolderやObjectContextHolderの初期化をする
        /// </summary>
        /// <param name="actionContext"></param>
        public override void OnActionExecuting(ActionExecutingContext actionContext)
        {
            CurrentInfoHolder.Init();
            CurrentInfoHolder.BindDateTimeToThread(DateTime.UtcNow.UtcToJapanStandardTime());


            ObjectContextHolder.ObjectContext();
            base.OnActionExecuting(actionContext);
        }
Example #5
0
        /// <summary>
        /// (複数)データをDBから削除する
        /// </summary>
        /// <param name="entities"></param>
        public void Delete(IEnumerable <TEntity> entities)
        {
            bool isSave = false;

            foreach (var entity in entities)
            {
                ObjectContextHolder.ObjectContext().DeleteObject(entity);
                isSave = true;
            }
            if (isSave)
            {
                ObjectContextHolder.ObjectContext().SaveChanges();
            }
        }
Example #6
0
        /// <summary>
        /// (複数)データをDBに更新する
        /// </summary>
        /// <param name="entities"></param>
        public void Update(IEnumerable <TEntity> entities)
        {
            bool isSave = false;

            foreach (var entity in entities)
            {
                ObjectContextHolder.ObjectContext().ApplyCurrentValues(typeof(TEntity).Name, entity);
                isSave = true;
            }
            if (isSave)
            {
                ObjectContextHolder.ObjectContext().SaveChanges();
            }
        }
Example #7
0
        /// <summary>
        /// データをDBに更新する
        /// </summary>
        /// <param name="update">更新用Expression</param>
        /// <param name="where">更新Where条件Expression</param>
        /// <returns>更新件数</returns>
        public int Update(Action <TEntity> update, Expression <Func <TEntity, bool> > where)
        {
            var query  = ObjectContextHolder.ObjectContext().CreateObjectSet <TEntity>().Where <TEntity>(where);
            var count  = 0;
            var isSave = false;

            foreach (var entity in query)
            {
                update(entity);
                isSave = true;
                count++;
            }
            if (isSave)
            {
                ObjectContextHolder.ObjectContext().SaveChanges();
            }
            return(count);
        }
Example #8
0
 /// <summary>
 /// データをDBから削除する
 /// </summary>
 /// <param name="entity"></param>
 public void Delete(TEntity entity)
 {
     ObjectContextHolder.ObjectContext().DeleteObject(entity);
     ObjectContextHolder.ObjectContext().SaveChanges();
 }
Example #9
0
 /// <summary>
 /// データをDBに更新する
 /// </summary>
 /// <param name="entity"></param>
 public void Update(TEntity entity)
 {
     ObjectContextHolder.ObjectContext().ApplyCurrentValues(typeof(TEntity).Name, entity);
     ObjectContextHolder.ObjectContext().SaveChanges();
 }
Example #10
0
 /// <summary>
 /// データをDBにインサートする
 /// </summary>
 /// <param name="entity">エンティティ</param>
 public void Save(TEntity entity)
 {
     ObjectContextHolder.ObjectContext().AddObject(typeof(TEntity).Name, entity);
     ObjectContextHolder.ObjectContext().SaveChanges();
 }
Example #11
0
        /// <summary>
        /// 検索
        /// </summary>
        /// <param name="predicate">Expression</param>
        /// <returns>結果</returns>
        public IEnumerable <TEntity> FindAny(Expression <Func <TEntity, bool> > predicate)
        {
            var query = ObjectContextHolder.ObjectContext().CreateObjectSet <TEntity>().Where(predicate);

            return(query.AsEnumerable());
        }
 /// <summary>
 /// CurrentInfoHolderやObjectContextHolderの解除をする
 /// </summary>
 /// <param name="actionExecutedContext"></param>
 public override void OnActionExecuted(ActionExecutedContext actionExecutedContext)
 {
     CurrentInfoHolder.Clear();
     ObjectContextHolder.Dispose();
     base.OnActionExecuted(actionExecutedContext);
 }
Example #13
0
        public IEnumerable <TEntity> FindAllWithDescAndAsc(Expression <Func <TEntity, object> > orderDescDelegate, Expression <Func <TEntity, object> > orderAscDelegate2)
        {
            var query = ObjectContextHolder.ObjectContext().CreateObjectSet <TEntity>().OrderByDescending(orderDescDelegate).ThenBy(orderAscDelegate2);

            return(query.AsEnumerable());
        }
Example #14
0
        public IEnumerable <TEntity> FindAllWithAsc(Expression <Func <TEntity, object> > orderDelegate)
        {
            var query = ObjectContextHolder.ObjectContext().CreateObjectSet <TEntity>().OrderBy(orderDelegate);

            return(query.AsEnumerable());
        }