Ejemplo n.º 1
0
        private void SetEmptyGuidKey(TEntity entity)
        {
            Type keyType = typeof(TKey);

            //自增int
            if (keyType == typeof(int))
            {
                IKeyGenerator <int> generator = _serviceProvider.GetService <IKeyGenerator <int> >();
                entity.Id = generator.Create().CastTo <TKey>();
                return;
            }
            //雪花long
            if (keyType == typeof(long))
            {
                IKeyGenerator <long> generator = _serviceProvider.GetService <IKeyGenerator <long> >();
                entity.Id = generator.Create().CastTo <TKey>();
            }
            //顺序guid
            if (keyType == typeof(Guid) && entity.Id.Equals(Guid.Empty))
            {
                DatabaseType             databaseType = _dbContext.GetDatabaseType();
                ISequentialGuidGenerator generator    =
                    _serviceProvider.GetServices <ISequentialGuidGenerator>().FirstOrDefault(m => m.DatabaseType == databaseType);
                entity.Id = generator == null?SequentialGuid.Create(databaseType).CastTo <TKey>() : generator.Create().CastTo <TKey>();
            }
        }
Ejemplo n.º 2
0
 public FindApplicationGateway(IDbConnection dbConnection, ISequentialGuidGenerator guidGenerator) : base(dbConnection, guidGenerator)
 {
 }
 public CreateDeckGateway(IDbConnection dbConnection, ISequentialGuidGenerator guidGenerator) : base(dbConnection, guidGenerator)
 {
 }
 public UrlShortenerImp()
 {
     urlShortenerRepository = new UrlShortenerRepository();
     guidGenerator          = new SequentialGuidGenerator();
 }
 protected FlashCardGateway(IDbConnection dbConnection, ISequentialGuidGenerator guidGenerator)
 {
     Db            = dbConnection;
     GuidGenerator = guidGenerator;
 }
 public GetApplicationByIdGateway(IDbConnection dbConnection, ISequentialGuidGenerator guidGenerator) : base(dbConnection, guidGenerator)
 {
 }
Ejemplo n.º 7
0
 public ListDeckCategoriesByApplicationGateway(IDbConnection dbConnection, ISequentialGuidGenerator guidGenerator) : base(dbConnection, guidGenerator)
 {
 }