Repositories-Impl.tt

1. Update the input arguments

Update the paths and namespace names at the top of the text template script according to your project. 


var targetPath = Host.ResolvePath("../../../KLO128.D3ORM.Sample.Infra.D3ORM/Repositories/");
var entitiesJsonPath = Host.ResolvePath("EntitiesFromEFCore.tt").Replace(".tt", ".json");
DefaultNameSpace = "KLO128.D3ORM.Sample.Infra.D3ORM.Repositories";
IfaceReposNameSpace = "KLO128.D3ORM.Sample.Domain.Repositories";
EntitiesNameSpace = "KLO128.D3ORM.Sample.Domain.Models.Entities";
DatabaseContextNames = new string [] {"D3ORMSampleContext"};

Input arguments are defined in the first 6 lines in this case and are divided by an empty line. 

  • targetPath is the folder path where the repository classes are generated or overwritten in. 
  • entittiesJsonPath is the configuration file path of the aggregations - necessary for determination if to extend ICommonRepository or IAggRootRepositoryIf not specified or not found, IAggRootRepository is used as the base interface. 
  • DefaultNameSpace is the namespace of the generated (target) class. 
  • IfaceReposNameSpace is the namespace of the repository interfaces. 
  • EntitiesNameSpaceis the namespace of the entities. 
  • DatabaseContextNames is an array of the local class/interface names without .cs suffix which should be excluded from the generation - typically EF Core DbContext. 

2. Run the Text Template Script

Run the text template to generate repository implementations. 

Example


///
/// generated file 01.09.2022 9:21:46
///

using System;
using System.Data;
using KLO128.D3ORM.Common;
using KLO128.D3ORM.Common.Impl;
using KLO128.D3ORM.Website.Domain.Models.Entities;
using KLO128.D3ORM.Website.Domain.Repositories;

namespace KLO128.D3ORM.Website.Infra.D3ORM.Repositories
{
    public class D3UserRepository : D3AggRootRepository<User>, IUserRepository
    {
        public D3UserRepository(IDbConnection Connection, ID3Context D3Context) : base(Connection, D3Context)
        {
        }
    }
}