Esempio n. 1
0
        public async Task <long> GetNextId(Type objType)
        {
            string pathName = objType.Name;

            try
            {
                long nextValue = await _commonRepository.GetNextValueForSequence(pathName);

                return(nextValue);
            }
            catch (SqlException e)
            {
                if (e.Message.StartsWith("Invalid object name 'Sequence"))
                {
                    await _commonRepository.CreateSequence(pathName);

                    long nextValue = await _commonRepository.GetNextValueForSequence(pathName);

                    return(nextValue);
                }
                throw;
            }
            catch (Exception e)
            {
                e.ExceptionAddParam("CommonService.GetNextId", objType);
                throw;
            }
        }