示例#1
0
        public override int Go()
        {
            if (string.IsNullOrWhiteSpace(ProcedureName))
            {
                throw new MissingProcedureNameException();
            }
            var name = "[" + SchemaName + "].[" + ProcedureName + "]";

            return(ParameterDefinitions.Any()
                ? StatementExecutor.ExecuteNonQueryStoredProcedure(name, ParameterDefinitions.ToArray())
                : StatementExecutor.ExecuteNonQueryStoredProcedure(name));
        }
示例#2
0
        public override IEnumerable <TEntity> Go()
        {
            if (string.IsNullOrWhiteSpace(ProcedureName))
            {
                ProcedureName = CustomAttributeHandle.DbTableName <TEntity>();
            }
            if (string.IsNullOrWhiteSpace(ProcedureName))
            {
                throw new MissingProcedureNameException();
            }
            var name = "[" + SchemaName + "].[" + ProcedureName + "]";

            using (var reader = ParameterDefinitions.Any()
                ? StatementExecutor.ExecuteStoredProcedure(name, ParameterDefinitions.ToArray())
                : StatementExecutor.ExecuteStoredProcedure(name))
                return(_entityMapper.Map <TEntity>(reader));
        }
示例#3
0
        public override async Task <int> GoAsync()
        {
            if (string.IsNullOrWhiteSpace(ProcedureName))
            {
                throw new MissingProcedureNameException();
            }
            var procedureName = "[" + SchemaName + "].[" + ProcedureName + "]";
            int num;

            if (ParameterDefinitions.Any())
            {
                num = await StatementExecutor.ExecuteNonQueryStoredProcedureAsync(procedureName,
                                                                                  ParameterDefinitions.ToArray());
            }
            else
            {
                num = await StatementExecutor.ExecuteNonQueryStoredProcedureAsync(procedureName);
            }
            return(num);
        }
示例#4
0
        public override async Task <IEnumerable <TEntity> > GoAsync()
        {
            if (string.IsNullOrWhiteSpace(ProcedureName))
            {
                ProcedureName = CustomAttributeHandle.DbTableName <TEntity>();
            }
            if (string.IsNullOrWhiteSpace(ProcedureName))
            {
                throw new MissingProcedureNameException();
            }
            var         procedureName = "[" + SchemaName + "].[" + ProcedureName + "]";
            IDataReader dataReader;

            if (ParameterDefinitions.Any())
            {
                dataReader =
                    await StatementExecutor.ExecuteStoredProcedureAsync(procedureName, ParameterDefinitions.ToArray());
            }
            else
            {
                dataReader = await StatementExecutor.ExecuteStoredProcedureAsync(procedureName);
            }
            var reader = dataReader;

            dataReader = null;
            IEnumerable <TEntity> entities;

            try
            {
                entities = entityMapper.Map <TEntity>(reader);
            }
            finally
            {
                reader?.Dispose();
            }

            return(entities);
        }