Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class OrderRepository : IOrderRepository
- {
- private readonly Func<SqlConnection> _locateSqlConnection;
- public OrderRepository(Func<SqlConnection> locateSqlConnection)
- {
- _locateSqlConnection = locateSqlConnection;
- }
- public Order ReadById(int id)
- {
- var connection = _locateSqlConnection();
- using (var command = connection.CreateCommand())
- {
- // Здесь загружаем данные, конструируем Order и возвращаем его
- . . .
- return new Order(id, createdAt, amount);
- }
- }
- . . .
- }
- builder.Register<OrderRepository>()
- .As<IOrderRepostitory>()
- .SingleInstance();
- builder.Register<SqlConnection>()
- .InstancePerRequest();
Add Comment
Please, Sign In to add comment