Ejemplo n.º 1
0
        public virtual TEntity QueryByKey <TEntity>(object key, string table, LockType @lock, bool tracking = false)
        {
            Expression <Func <TEntity, bool> > condition = PrimaryKeyHelper.BuildCondition <TEntity>(key);
            var q = this.Query <TEntity>(table, @lock).Where(condition);

            if (tracking)
            {
                q = q.AsTracking();
            }

            return(q.FirstOrDefault());
        }
Ejemplo n.º 2
0
        protected virtual async Task <TEntity> QueryByKey <TEntity>(object key, string table, LockType @lock, bool tracking, bool @async)
        {
            Expression <Func <TEntity, bool> > condition = PrimaryKeyHelper.BuildCondition <TEntity>(key);
            var q = this.Query <TEntity>(table, @lock).Where(condition);

            if (tracking)
            {
                q = q.AsTracking();
            }

            if (@async)
            {
                return(await q.FirstOrDefaultAsync());
            }

            return(q.FirstOrDefault());
        }
Ejemplo n.º 3
0
        protected virtual async Task <int> DeleteByKey <TEntity>(object key, string table, bool @async)
        {
            Expression <Func <TEntity, bool> > condition = PrimaryKeyHelper.BuildCondition <TEntity>(key);

            return(await this.Delete <TEntity>(condition, table, @async));
        }
Ejemplo n.º 4
0
        public virtual int DeleteByKey <TEntity>(object key, string table)
        {
            Expression <Func <TEntity, bool> > condition = PrimaryKeyHelper.BuildCondition <TEntity>(key);

            return(this.Delete <TEntity>(condition, table));
        }