79613061

Date: 2025-05-08 19:43:54
Score: 0.5
Natty:
Report link

I found a method, but it is not complete. I wrote a T4 file as follows:

<#
    // Define your model types
    var models = new string[] { "Academic", "Ostad", "Course" };
#>
using Core.Interfaces;
using DataAccessLibrary.Models;
using Microsoft.AspNetCore.Mvc;

namespace Snapp.site.Controllers
{
<#
    foreach (var model in models)
    {
#>
    public class <#= model #>Controller : GenericController<<#= model #>>
    {
        public <#= model #>Controller(IRepository<<#= model #>> repository) : base(repository) { }
    }
<#
    } // Closing foreach loop
#>
}

But I can't dynamically generate the models array.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: amir