Last active
September 14, 2022 11:27
-
-
Save pimbrouwers/3222f1ed5007e20af217d0c9a28728e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Reflection; | |
namespace Project.Repo | |
{ | |
public interface IMapper<TEntity> where TEntity : class | |
{ | |
IEnumerable<PropertyInfo> Properties { get; } | |
Type Type { get; } | |
Dictionary<string, object> ReadPropertyValues(TEntity entity, IEnumerable<string> properties); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Data; | |
using System.Threading.Tasks; | |
namespace Project.Repo | |
{ | |
public interface IRepository<TEntity> where TEntity : class | |
{ | |
ISqlConnectionFactory ConnectionFactory { get; } | |
ITable<TEntity> Table { get; } | |
Task<int> Execute(string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType commandType = CommandType.Text, IDbConnection conn = null); | |
Task<IEnumerable<T>> Query<T>(string sql, object param = null, IDbTransaction transaction = null, CommandType commandType = CommandType.Text); | |
Task<T> First<T>(string sql, object param = null, IDbTransaction transaction = null, CommandType commandType = CommandType.Text); | |
Task<IEnumerable<TEntity>> GetAll(); | |
Task<TEntity> Get(int id); | |
Task<int> Create(TEntity entity, IDbTransaction transaction = null); | |
Task<bool> Update(TEntity entity, IDbTransaction transaction = null); | |
Task<bool> Delete(TEntity entity, IDbTransaction transaction = null); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Data.SqlClient; | |
using System.Threading.Tasks; | |
namespace Project.Repo | |
{ | |
public interface ISqlConnectionFactory | |
{ | |
string ConnectionString { get; } | |
Task<SqlConnection> CreateOpenConnection(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Project.Repo | |
{ | |
public interface ITable<TEntity> where TEntity : class | |
{ | |
IMapper<TEntity> Mapper { get; } | |
string[] Fields { get; } | |
string[] FieldsQualified { get; } | |
string Key { get; } | |
string[] NonKeyFields { get; } | |
string[] NonKeyFieldsQualified { get; } | |
string Name { get; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment