Exemple #1
0
        public ErrorLog FindById(Guid errorLogId)
        {
            try
            {
                const string query = @"SELECT
											[ErrorLogId],
											[Message],
											[InnerException],
											[CreatedById],
											[CreatedByOn],
											[CreatedByIp],
											[ModifiedById],
											[ModifiedOn],
											[ModifiedByIp]
									FROM User
									WHERE ErrorLogId = @ErrorLogId"                                    ;

                using (var connection = _factory.GetConnection())
                {
                    return(connection.Query <ErrorLog>(query, new
                    {
                        ErrorLogId = errorLogId
                    }).FirstOrDefault());
                }
            }
            catch (Exception ex)
            {
                return(new ErrorLog());
            }
        }
Exemple #2
0
        public User FindById(Guid userId)
        {
            try
            {
                const string query = @"SELECT
											[UserId],
											[Email],
											[CreatedById],
											[CreatedByOn],
											[CreatedByIp],
											[ModifiedById],
											[ModifiedOn],
											[ModifiedByIp]
									FROM User
									WHERE UserId = @UserId"                                    ;

                using (var connection = _factory.GetConnection())
                {
                    return(connection.Query <User>(query, new
                    {
                        UserId = userId
                    }).FirstOrDefault());
                }
            }
            catch (Exception ex)
            {
                return(new User());
            }
        }
Exemple #3
0
        public void TestMsConnection()
        {
            IDbConnection conn = DbConnectionFactory.GetConnection(DbSource.MicrosoftSQL);
            var           res  = conn.Query(@"select product_id from lovelife_dev.dbo.product_info");

            conn.Execute(@"INSERT INTO lovelife_dev.dbo.product_info (product_id)
                            VALUES (456);");

            Console.WriteLine(res);
        }
        public void ShouldGetPostgresSqlConnection()
        {
            // Arrange
            var dbConnectionFactory = new DbConnectionFactory();
            var dbType           = DatabaseType.PostgreSQL;
            var connectionString = "";

            // Act
            var sut = dbConnectionFactory.GetConnection(dbType, connectionString);

            // Assert
            TestConnection(sut, connectionString);
        }
        public void ShouldGetSQLConnection()
        {
            //Given / Arrange
            var dbConnectionFactory = new DbConnectionFactory();
            var dbType           = DatabaseType.SqlServer;
            var connectionString = "";

            //When / Act
            var sut = dbConnectionFactory.GetConnection(dbType, connectionString);

            //Then / Assert
            TestConnection(sut, connectionString);
        }
        public async Task DeclareAnimeToBeDisplayedAsync(IEnumerable <int> malAnimeIds)
        {
            if (DbConnectionFactory == null)
            {
                return;                              // Null is passed when precompiling the views
            }
            using (IAnimeRecsDbConnection conn = DbConnectionFactory.GetConnection())
            {
                await conn.OpenAsync().ConfigureAwait(false);

                StreamsByAnime = await conn.GetStreamsAsync(malAnimeIds).ConfigureAwait(false);
            }
        }
 public MsProductRepository()
 {
     _conn = DbConnectionFactory.GetConnection(DbSource.MicrosoftSQL);
 }