Ejemplo n.º 1
0
        public TEntity Get(dynamic id, IUnitOfWork uow = null, string tableName = null, bool rowLock = false)
        {
            var dynParams = GetParameters(id);
            var sql       = rowLock ? _sql.GetAndRowLock(tableName) : _sql.Get(tableName);

            _logger?.LogDebug("Get:{@sql}", sql);
            return(QuerySingleOrDefault <TEntity>(sql, dynParams, uow));
        }
Ejemplo n.º 2
0
        protected override void Execute(NativeActivityContext context)
        {
            // get the ambient Entity Framework object context
            ObjectContext efObjectContext = context.Properties.Find(ObjectContextScope.ObjectContextPropertyName) as ObjectContext;

            if (efObjectContext == null)
            {
                throw new ValidationException("Entity Framework Object Context not found");
            }

            ObjectQuery <TResult> query;

            // setup parameters
            if (this.parameters.Count() > 0)
            {
                ObjectParameter[] objectParameters = new ObjectParameter[this.Parameters.Count()];
                int i = 0;
                foreach (KeyValuePair <string, Argument> item in this.Parameters)
                {
                    objectParameters[i] = new ObjectParameter(item.Key, item.Value.Get(context));
                    i++;
                }
                query = efObjectContext.CreateQuery <TResult>(EntitySql.Get(context), objectParameters);
            }
            else
            {
                query = efObjectContext.CreateQuery <TResult>(EntitySql.Get(context));
            }

            // set the result value
            Result.Set(context, query.ToList <TResult>());
        }
Ejemplo n.º 3
0
        public TEntity Get(dynamic id, IUnitOfWork uow = null, string tableName = null, bool rowLock = false, bool noLock = false)
        {
            var    dynParams = GetParameters(id);
            string sql;

            if (rowLock)
            {
                sql = _sql.GetAndRowLock(tableName);
            }
            else if (_sqlAdapter.SqlDialect == SqlDialect.SqlServer && noLock)
            {
                sql = _sql.GetAndNoLock(tableName);
            }
            else
            {
                sql = _sql.Get(tableName);
            }

            _logger?.LogDebug("Get:{@sql}", sql);
            return(QuerySingleOrDefault <TEntity>(sql, dynParams, uow));
        }
Ejemplo n.º 4
0
        public TEntity Get(dynamic id, IDbTransaction transaction = null, string tableName = null)
        {
            var dynParams = GetParameters(id);

            return(QuerySingleOrDefault <TEntity>(_sql.Get(tableName), dynParams, transaction));
        }