Example #1
0
        private IEnumerable <T> PerformFind(string whereClause)
        {
            IEnumerable <T> models;

            using (var connection = GetDatabaseConnection())
            {
                connection.Open();
                Logger.Verbose($"{RepositorySql.GetFindStatement()} {whereClause}");
                models = connection.Query <T>($"{RepositorySql.GetFindStatement()} {whereClause}");
            }

            return(models);
        }
Example #2
0
        private IEnumerable <T> PerformFetch(T model)
        {
            IEnumerable <T> models;

            using (var connection = GetDatabaseConnection())
            {
                connection.Open();
                Logger.Verbose(RepositorySql.GetFetchStatement());
                models = connection.Query <T>(RepositorySql.GetFetchStatement(), model);
            }

            return(models);
        }
Example #3
0
        private int?PerformInsert(T model)
        {
            int?id;

            using (var connection = GetDatabaseConnection())
            {
                connection.Open();
                Logger.Verbose(RepositorySql.GetCreateStatement());
                id = connection.Query <int>(RepositorySql.GetCreateStatement(), model).First();
            }

            return(id);
        }
Example #4
0
        private int PerformDelete(T model)
        {
            int rows = 0;

            using (var connection = GetDatabaseConnection())
            {
                connection.Open();
                Logger.Verbose(RepositorySql.GetDeleteStatement());
                rows = connection.Execute(RepositorySql.GetDeleteStatement(), model);
            }

            return(rows);
        }
Example #5
0
        private int PerformUpdate(T model)
        {
            int rows = 0;

            using (var connection = GetDatabaseConnection())
            {
                connection.Open();
                Logger.Verbose(RepositorySql.GetUpdateStatement());
                Logger.Verbose($"ID: {GetId(model)}, GUID: {GetGuid(model)}");
                rows = connection.Execute(RepositorySql.GetUpdateStatement(), model);
            }

            return(rows);
        }