public IEnumerable <Detail> GetAll()
        {
            SqlConnection connection = AdoNetConnection.DatabaseConnect();

            var sql    = "SELECT * FROM Details";
            var result = new List <Detail>();

            using (connection)
            {
                connection.Open();

                SqlCommand command = new SqlCommand(sql, connection);

                SqlDataReader reader = command.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        result.Add(new Detail
                        {
                            Id         = (int)reader["Id"],
                            CarId      = (int)reader["CarId"],
                            DetailName = (string)reader["DetailName"],
                            Cost       = (int)reader["Cost"]
                        });
                    }
                    connection.Close();
                }
                return(result);
            }
        }
        public IEnumerable <Car> GetAll()
        {
            SqlConnection connection = AdoNetConnection.DatabaseConnect();

            var sql    = $"SELECT * FROM Cars";
            var result = new List <Car>();

            using (connection)
            {
                connection.Open();

                SqlCommand command = new SqlCommand(sql, connection);

                SqlDataReader reader = command.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        result.Add(new Car
                        {
                            Id    = (int)reader["Id"],
                            Model = (string)reader["Model"]
                        });
                    }
                }
                connection.Close();
            }
            return(result);
        }
        public static void Main()
        {
            var connection = new AdoNetConnection();
            var db         = new Database(connection);

            var numberOfCustomers =
                db.Query <int>("SELECT COUNT(ID) FROM Customers WHERE RegisteredTimestamp BETWEEN @Start AND @End",
                               new { Start = new DateTime(2020, 1, 1), End = new DateTime(2020, 1, 31) });
        }
        public override void open_connection(bool with_transaction)
        {
            server_connection = new AdoNetConnection(new OleDbConnection(connection_string));
            server_connection.open();

            set_repository();

            if (with_transaction)
            {
                transaction = server_connection.underlying_type().BeginTransaction();
                repository.start(true);
            }
        }
        public override void open_connection(bool with_transaction)
        {
            server_connection = new AdoNetConnection(new OleDbConnection(connection_string));
            server_connection.open();

            set_repository();

            if (with_transaction)
            {
                transaction = server_connection.underlying_type().BeginTransaction();
                repository.start(true);
            }
        }
        public override void open_connection(bool with_transaction)
        {
            Log.bound_to(this).log_a_debug_event_containing("Opening connection to '{0}'", connection_string);
            server_connection = new AdoNetConnection(new SqlCeConnection(connection_string));
            server_connection.open();

            if (with_transaction)
            {
                transaction = server_connection.underlying_type().BeginTransaction();
            }

            set_repository();
            if (repository != null)
            {
                repository.start(with_transaction);
            }
        }
 public override void open_admin_connection()
 {
     admin_connection = new AdoNetConnection(new OleDbConnection(admin_connection_string));
     admin_connection.open();
 }
Exemple #8
0
 public override void open_admin_connection()
 {
     admin_connection = new AdoNetConnection(new OleDbConnection(admin_connection_string));
     admin_connection.open();
 }
 public override void open_admin_connection()
 {
     Log.bound_to(this).log_a_debug_event_containing("Opening admin connection to '{0}'", connection_string);
     server_connection = new AdoNetConnection(new SqlCeConnection(connection_string));
     server_connection.open();
 }
Exemple #10
0
 public AccessDatabase()
 {
     server_connection = new AdoNetConnection(new OleDbConnection(connection_string));
 }