<#@ Template debug="false"Hostspecific="false"Language="C #"#><#@ Assembly Name="Microsoft.csharp"#><#@ Assembly Name="System.core"#><#@ Importnamespace="System.Linq"#><#@ Importnamespace="System.Text"#><#@ Assembly Name="System.Data"#><#@ Importnamespace="System.Collections.Generic"#><#@ Importnamespace="System.Data.SqlClient"#><#@ Importnamespace="system.dynamic"#><#@ Output extension=". CS"#><# varNamespacename="Reap.DAL.Repositories"; varConnectionString =@"data source=xxx;initial catalog=xxx; User Id=sa; password=xx;"; using(vardb =NewSqlConnection (connectionString))using(varcmd =db. CreateCommand ()) {db. Open (); vartables= readrows (cmd,"SELECT * from sys.tables WHERE name<> ' __migrationhistory '"). ToArray (); #>usingReap.Models.Models;usingReap.IDAL.Repositories;usingReap.DAL.UnitOfWork;namespace<#=namespaceName#>{ <# foreach(varTableinchtables) { #> Public classI<#=table.name#>repository:efrepositorybase<<#=table.name#>>,i<#=table.name#>repository{}<# } } #> } <#+Staticienumerable<dynamic> readrows (SqlCommand command,stringSQL) {Command.commandtext= SQL??""; using(varReader =command. ExecuteReader ()) { while(reader. Read ()) {varDyn =NewExpandoObject (); IDictionary<string,Object> dic =dyn; for(varITER =0; ITER < reader. FieldCount; ++ITER) {Dic[reader. GetName (ITER)??""] =Reader. GetValue (ITER); } yield returndyn; } } } #>