<#@ template language="C#" HostSpecific="True" #>
<#@ output extension="cs" #>
<#@ include file="..\..\ControllerHead.cs.include.t4" #>
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Data.SqlClient;

// This code was generated by C1 Scaffolder.

<#
	var columns = Options["Columns"];
#>
namespace <#= Namespace #>
{
    public partial class <#= ControllerName #> : Controller
    {
        private <#= DbContextTypeName #> db;

        public <#= ControllerName #>(<#= DbContextTypeName #> context)
        {
            db = context;
        }

        public ActionResult <#= ViewName #>()
        {
            var model = db.<#= EntitySetName #>;
<#@ include file="..\..\DataMapViewBag.cs.include.t4" #>
            return View(model);
        }

<#
	var primaryKeys = "";
	if(PrimaryKeys != null && PrimaryKeys.Count > 0)
	{
		primaryKeys = string.Join(", ", PrimaryKeys.Select(p => "item." + p.Key));
	}

	// ReadActionUrl
	if(!string.IsNullOrEmpty(Options["ReadActionUrl"]))
	{
#>
        public ActionResult <#= Options["ReadActionUrl"] #>([C1JsonRequest] CollectionViewRequest<<#= ViewDataTypeName #>> requestData)
        {
<#@ include file="..\..\CVRead.cs.include.t4" #>
        }

<#
	}
#>
<#@ include file="..\..\CVEdit.Core.cs.include.t4" #>
<#@ include file="..\..\DataMapAction.cs.include.t4" #>
    }
}