Commit c52cc697 authored by Sam Saffron's avatar Sam Saffron

merge

parents 536fed0d 2dfa6423
......@@ -98,8 +98,27 @@ public void Run(int iterations)
var massiveConnection = Program.GetOpenConnection();
tests.Add(id => massiveModel.Query("select * from Posts where Id = @0", massiveConnection, id).ToList(), "Dynamic Massive ORM Query");
// HAND CODED
// PetaPoco test with all default options
var petapoco = new PetaPoco.Database(Program.connectionString, "System.Data.SqlClient");
petapoco.OpenSharedConnection();
tests.Add(id => petapoco.Fetch<Post>("SELECT * from Posts where Id=@0", id), "PetaPoco (Normal)");
// PetaPoco with some "smart" functionality disabled
var petapocoFast = new PetaPoco.Database(Program.connectionString, "System.Data.SqlClient");
petapocoFast.OpenSharedConnection();
petapocoFast.EnableAutoSelect = false;
petapocoFast.EnableNamedParams = false;
petapocoFast.ForceDateTimesToUtc = false;
tests.Add(id => petapocoFast.Fetch<Post>("SELECT * from Posts where Id=@0", id), "PetaPoco (Fast)");
// Subsonic ActiveRecord
tests.Add(id => SubSonic.Post.SingleOrDefault(x => x.Id == id), "SubSonic ActiveRecord.SingleOrDefault");
// Subsonic ActiveRecord
SubSonic.tempdbDB db=new SubSonic.tempdbDB();
tests.Add(id => new SubSonic.Query.CodingHorror(db.Provider, "select * from Posts where Id = @0", id).ExecuteTypedList<Post>(), "SubSonic Coding Horror");
// HAND CODED
var connection = Program.GetOpenConnection();
......
This diff is collapsed.
......@@ -35,7 +35,11 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="SubSonic.Core">
<HintPath>SubSonic\SubSonic.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Data.Entity" />
<Reference Include="System.Data.Linq" />
......@@ -61,6 +65,7 @@
<Compile Include="Linq2Sql\Post.cs" />
<Compile Include="Massive\Massive.cs" />
<Compile Include="PerformanceTests.cs" />
<Compile Include="PetaPoco\PetaPoco.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
......@@ -69,6 +74,26 @@
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="SqlMapper.cs" />
<Compile Include="SubSonic\ActiveRecord.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>ActiveRecord.tt</DependentUpon>
</Compile>
<Compile Include="SubSonic\Context.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Context.tt</DependentUpon>
</Compile>
<Compile Include="SubSonic\StoredProcedures.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>StoredProcedures.tt</DependentUpon>
</Compile>
<Compile Include="SubSonic\Structs.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Structs.tt</DependentUpon>
</Compile>
<Compile Include="Tests.cs" />
</ItemGroup>
<ItemGroup>
......@@ -86,15 +111,35 @@
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<None Include="SubSonic\ActiveRecord.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>ActiveRecord.cs</LastGenOutput>
</None>
<None Include="SubSonic\Context.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Context.cs</LastGenOutput>
</None>
<None Include="SubSonic\Settings.ttinclude" />
<None Include="SubSonic\SQLServer.ttinclude" />
<None Include="SubSonic\StoredProcedures.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>StoredProcedures.cs</LastGenOutput>
</None>
<None Include="SubSonic\Structs.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Structs.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Service Include="{3259AA49-8AA1-44D3-9025-A0B520596A8C}" />
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup>
<None Include="Linq2Sql\DataClasses.dbml.layout">
<DependentUpon>DataClasses.dbml</DependentUpon>
</None>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
......
This diff is collapsed.
This diff is collapsed.
using System;
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using SubSonic.DataProviders;
using SubSonic.Extensions;
using SubSonic.Linq.Structure;
using SubSonic.Query;
using SubSonic.Schema;
using System.Data.Common;
using System.Collections.Generic;
namespace SubSonic
{
public partial class tempdbDB : IQuerySurface
{
public IDataProvider DataProvider;
public DbQueryProvider provider;
public static IDataProvider DefaultDataProvider { get; set; }
public bool TestMode
{
get
{
return DataProvider.ConnectionString.Equals("test", StringComparison.InvariantCultureIgnoreCase);
}
}
public tempdbDB()
{
if (DefaultDataProvider == null) {
DataProvider = ProviderFactory.GetProvider("Smackdown.Properties.Settings.tempdbConnectionString");
}
else {
DataProvider = DefaultDataProvider;
}
Init();
}
public tempdbDB(string connectionStringName)
{
DataProvider = ProviderFactory.GetProvider(connectionStringName);
Init();
}
public tempdbDB(string connectionString, string providerName)
{
DataProvider = ProviderFactory.GetProvider(connectionString,providerName);
Init();
}
public ITable FindByPrimaryKey(string pkName)
{
return DataProvider.Schema.Tables.SingleOrDefault(x => x.PrimaryKey.Name.Equals(pkName, StringComparison.InvariantCultureIgnoreCase));
}
public Query<T> GetQuery<T>()
{
return new Query<T>(provider);
}
public ITable FindTable(string tableName)
{
return DataProvider.FindTable(tableName);
}
public IDataProvider Provider
{
get { return DataProvider; }
set {DataProvider=value;}
}
public DbQueryProvider QueryProvider
{
get { return provider; }
}
BatchQuery _batch = null;
public void Queue<T>(IQueryable<T> qry)
{
if (_batch == null)
_batch = new BatchQuery(Provider, QueryProvider);
_batch.Queue(qry);
}
public void Queue(ISqlQuery qry)
{
if (_batch == null)
_batch = new BatchQuery(Provider, QueryProvider);
_batch.Queue(qry);
}
public void ExecuteTransaction(IList<DbCommand> commands)
{
if(!TestMode)
{
using(var connection = commands[0].Connection)
{
if (connection.State == ConnectionState.Closed)
connection.Open();
using (var trans = connection.BeginTransaction())
{
foreach (var cmd in commands)
{
cmd.Transaction = trans;
cmd.Connection = connection;
cmd.ExecuteNonQuery();
}
trans.Commit();
}
connection.Close();
}
}
}
public IDataReader ExecuteBatch()
{
if (_batch == null)
throw new InvalidOperationException("There's nothing in the queue");
if(!TestMode)
return _batch.ExecuteReader();
return null;
}
public Query<Post> Posts { get; set; }
#region ' Aggregates and SubSonic Queries '
public Select SelectColumns(params string[] columns)
{
return new Select(DataProvider, columns);
}
public Select Select
{
get { return new Select(this.Provider); }
}
public Insert Insert
{
get { return new Insert(this.Provider); }
}
public Update<T> Update<T>() where T:new()
{
return new Update<T>(this.Provider);
}
public SqlQuery Delete<T>(Expression<Func<T,bool>> column) where T:new()
{
LambdaExpression lamda = column;
SqlQuery result = new Delete<T>(this.Provider);
result = result.From<T>();
result.Constraints=lamda.ParseConstraints().ToList();
return result;
}
public SqlQuery Max<T>(Expression<Func<T,object>> column)
{
LambdaExpression lamda = column;
string colName = lamda.ParseObjectValue();
string objectName = typeof(T).Name;
string tableName = DataProvider.FindTable(objectName).Name;
return new Select(DataProvider, new Aggregate(colName, AggregateFunction.Max)).From(tableName);
}
public SqlQuery Min<T>(Expression<Func<T,object>> column)
{
LambdaExpression lamda = column;
string colName = lamda.ParseObjectValue();
string objectName = typeof(T).Name;
string tableName = this.Provider.FindTable(objectName).Name;
return new Select(this.Provider, new Aggregate(colName, AggregateFunction.Min)).From(tableName);
}
public SqlQuery Sum<T>(Expression<Func<T,object>> column)
{
LambdaExpression lamda = column;
string colName = lamda.ParseObjectValue();
string objectName = typeof(T).Name;
string tableName = this.Provider.FindTable(objectName).Name;
return new Select(this.Provider, new Aggregate(colName, AggregateFunction.Sum)).From(tableName);
}
public SqlQuery Avg<T>(Expression<Func<T,object>> column)
{
LambdaExpression lamda = column;
string colName = lamda.ParseObjectValue();
string objectName = typeof(T).Name;
string tableName = this.Provider.FindTable(objectName).Name;
return new Select(this.Provider, new Aggregate(colName, AggregateFunction.Avg)).From(tableName);
}
public SqlQuery Count<T>(Expression<Func<T,object>> column)
{
LambdaExpression lamda = column;
string colName = lamda.ParseObjectValue();
string objectName = typeof(T).Name;
string tableName = this.Provider.FindTable(objectName).Name;
return new Select(this.Provider, new Aggregate(colName, AggregateFunction.Count)).From(tableName);
}
public SqlQuery Variance<T>(Expression<Func<T,object>> column)
{
LambdaExpression lamda = column;
string colName = lamda.ParseObjectValue();
string objectName = typeof(T).Name;
string tableName = this.Provider.FindTable(objectName).Name;
return new Select(this.Provider, new Aggregate(colName, AggregateFunction.Var)).From(tableName);
}
public SqlQuery StandardDeviation<T>(Expression<Func<T,object>> column)
{
LambdaExpression lamda = column;
string colName = lamda.ParseObjectValue();
string objectName = typeof(T).Name;
string tableName = this.Provider.FindTable(objectName).Name;
return new Select(this.Provider, new Aggregate(colName, AggregateFunction.StDev)).From(tableName);
}
#endregion
void Init()
{
provider = new DbQueryProvider(this.Provider);
#region ' Query Defs '
Posts = new Query<Post>(provider);
#endregion
#region ' Schemas '
if(DataProvider.Schema.Tables.Count == 0)
{
DataProvider.Schema.Tables.Add(new PostsTable(DataProvider));
}
#endregion
}
#region ' Helpers '
internal static DateTime DateTimeNowTruncatedDownToSecond() {
var now = DateTime.Now;
return now.AddTicks(-now.Ticks % TimeSpan.TicksPerSecond);
}
#endregion
}
}
\ No newline at end of file
<#@ template language="C#v3.5" debug="False" hostspecific="True" #>
<#@ output extension=".cs" #>
<#@ include file="SQLServer.ttinclude" #>
<#
var tables = LoadTables();
#>
using System;
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using SubSonic.DataProviders;
using SubSonic.Extensions;
using SubSonic.Linq.Structure;
using SubSonic.Query;
using SubSonic.Schema;
using System.Data.Common;
using System.Collections.Generic;
namespace <#=Namespace#>
{
public partial class <#=DatabaseName#>DB : IQuerySurface
{
public IDataProvider DataProvider;
public DbQueryProvider provider;
public static IDataProvider DefaultDataProvider { get; set; }
public bool TestMode
{
get
{
return DataProvider.ConnectionString.Equals("test", StringComparison.InvariantCultureIgnoreCase);
}
}
public <#=DatabaseName#>DB()
{
if (DefaultDataProvider == null) {
DataProvider = ProviderFactory.GetProvider("<#=ConnectionStringName#>");
}
else {
DataProvider = DefaultDataProvider;
}
Init();
}
public <#=DatabaseName#>DB(string connectionStringName)
{
DataProvider = ProviderFactory.GetProvider(connectionStringName);
Init();
}
public <#=DatabaseName#>DB(string connectionString, string providerName)
{
DataProvider = ProviderFactory.GetProvider(connectionString,providerName);
Init();
}
public ITable FindByPrimaryKey(string pkName)
{
return DataProvider.Schema.Tables.SingleOrDefault(x => x.PrimaryKey.Name.Equals(pkName, StringComparison.InvariantCultureIgnoreCase));
}
public Query<T> GetQuery<T>()
{
return new Query<T>(provider);
}
public ITable FindTable(string tableName)
{
return DataProvider.FindTable(tableName);
}
public IDataProvider Provider
{
get { return DataProvider; }
set {DataProvider=value;}
}
public DbQueryProvider QueryProvider
{
get { return provider; }
}
BatchQuery _batch = null;
public void Queue<T>(IQueryable<T> qry)
{
if (_batch == null)
_batch = new BatchQuery(Provider, QueryProvider);
_batch.Queue(qry);
}
public void Queue(ISqlQuery qry)
{
if (_batch == null)
_batch = new BatchQuery(Provider, QueryProvider);
_batch.Queue(qry);
}
public void ExecuteTransaction(IList<DbCommand> commands)
{
if(!TestMode)
{
using(var connection = commands[0].Connection)
{
if (connection.State == ConnectionState.Closed)
connection.Open();
using (var trans = connection.BeginTransaction())
{
foreach (var cmd in commands)
{
cmd.Transaction = trans;
cmd.Connection = connection;
cmd.ExecuteNonQuery();
}
trans.Commit();
}
connection.Close();
}
}
}
public IDataReader ExecuteBatch()
{
if (_batch == null)
throw new InvalidOperationException("There's nothing in the queue");
if(!TestMode)
return _batch.ExecuteReader();
return null;
}
<# //################################################ IQueryable ####################################### #>
<# foreach(Table tbl in tables){
if(!ExcludeTables.Contains(tbl.Name))
{
#>
public Query<<#=tbl.ClassName#>> <#=tbl.QueryableName#> { get; set; }
<#
}
}
#>
<# //################################################ Aggregates and Queries ####################################### #>
#region ' Aggregates and SubSonic Queries '
public Select SelectColumns(params string[] columns)
{
return new Select(DataProvider, columns);
}
public Select Select
{
get { return new Select(this.Provider); }
}
public Insert Insert
{
get { return new Insert(this.Provider); }
}
public Update<T> Update<T>() where T:new()
{
return new Update<T>(this.Provider);
}
public SqlQuery Delete<T>(Expression<Func<T,bool>> column) where T:new()
{
LambdaExpression lamda = column;
SqlQuery result = new Delete<T>(this.Provider);
result = result.From<T>();
result.Constraints=lamda.ParseConstraints().ToList();
return result;
}
public SqlQuery Max<T>(Expression<Func<T,object>> column)
{
LambdaExpression lamda = column;
string colName = lamda.ParseObjectValue();
string objectName = typeof(T).Name;
string tableName = DataProvider.FindTable(objectName).Name;
return new Select(DataProvider, new Aggregate(colName, AggregateFunction.Max)).From(tableName);
}
public SqlQuery Min<T>(Expression<Func<T,object>> column)
{
LambdaExpression lamda = column;
string colName = lamda.ParseObjectValue();
string objectName = typeof(T).Name;
string tableName = this.Provider.FindTable(objectName).Name;
return new Select(this.Provider, new Aggregate(colName, AggregateFunction.Min)).From(tableName);
}
public SqlQuery Sum<T>(Expression<Func<T,object>> column)
{
LambdaExpression lamda = column;
string colName = lamda.ParseObjectValue();
string objectName = typeof(T).Name;
string tableName = this.Provider.FindTable(objectName).Name;
return new Select(this.Provider, new Aggregate(colName, AggregateFunction.Sum)).From(tableName);
}
public SqlQuery Avg<T>(Expression<Func<T,object>> column)
{
LambdaExpression lamda = column;
string colName = lamda.ParseObjectValue();
string objectName = typeof(T).Name;
string tableName = this.Provider.FindTable(objectName).Name;
return new Select(this.Provider, new Aggregate(colName, AggregateFunction.Avg)).From(tableName);
}
public SqlQuery Count<T>(Expression<Func<T,object>> column)
{
LambdaExpression lamda = column;
string colName = lamda.ParseObjectValue();
string objectName = typeof(T).Name;
string tableName = this.Provider.FindTable(objectName).Name;
return new Select(this.Provider, new Aggregate(colName, AggregateFunction.Count)).From(tableName);
}
public SqlQuery Variance<T>(Expression<Func<T,object>> column)
{
LambdaExpression lamda = column;
string colName = lamda.ParseObjectValue();
string objectName = typeof(T).Name;
string tableName = this.Provider.FindTable(objectName).Name;
return new Select(this.Provider, new Aggregate(colName, AggregateFunction.Var)).From(tableName);
}
public SqlQuery StandardDeviation<T>(Expression<Func<T,object>> column)
{
LambdaExpression lamda = column;
string colName = lamda.ParseObjectValue();
string objectName = typeof(T).Name;
string tableName = this.Provider.FindTable(objectName).Name;
return new Select(this.Provider, new Aggregate(colName, AggregateFunction.StDev)).From(tableName);
}
#endregion
void Init()
{
provider = new DbQueryProvider(this.Provider);
<#
//################################################ QUERIES ####################################### #>
#region ' Query Defs '
<#
foreach(Table tbl in tables)
{
if(!ExcludeTables.Contains(tbl.Name))
{
#>
<#=tbl.QueryableName#> = new Query<<#=tbl.ClassName#>>(provider);
<#
}
#>
<#
}
#>
#endregion
<#//################################################ SCHEMAS ####################################### #>
#region ' Schemas '
if(DataProvider.Schema.Tables.Count == 0)
{
<#
foreach(Table tbl in tables)
{
if(!ExcludeTables.Contains(tbl.Name))
{
#>
DataProvider.Schema.Tables.Add(new <#=tbl.CleanName#>Table(DataProvider));
<#
}
}
#>
}
#endregion
}
<#//################################################ HELPERS ####################################### #>
#region ' Helpers '
internal static DateTime DateTimeNowTruncatedDownToSecond() {
var now = DateTime.Now;
return now.AddTicks(-now.Ticks % TimeSpan.TicksPerSecond);
}
#endregion
}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.

\ No newline at end of file
<#@ template language="C#v3.5" debug="False" hostspecific="True" #>
<#@ output extension=".cs" #>
<#@ include file="SQLServer.ttinclude" #>
<#
var sps = GetSPs();
if(sps.Count>0){
#>
using System;
using SubSonic;
using SubSonic.Schema;
using SubSonic.DataProviders;
using System.Data;
namespace <#=Namespace#>{
public partial class <#=DatabaseName#>DB{
<# foreach(var sp in sps){#>
public StoredProcedure <#=sp.CleanName#>(<#=sp.ArgList#>){
StoredProcedure sp=new StoredProcedure("<#=sp.Name#>",this.Provider);
<# foreach(var par in sp.Parameters){#>
sp.Command.AddParameter("<#=par.Name#>",<#=par.CleanName#>,DbType.<#=par.DbType#>);
<# }#>
return sp;
}
<# }#>
}
}
<# }#>
\ No newline at end of file
using System;
using SubSonic.Schema;
using System.Collections.Generic;
using SubSonic.DataProviders;
using System.Data;
namespace SubSonic {
/// <summary>
/// Table: Posts
/// Primary Key: Id
/// </summary>
public class PostsTable: DatabaseTable {
public PostsTable(IDataProvider provider):base("Posts",provider){
ClassName = "Post";
SchemaName = "dbo";
Columns.Add(new DatabaseColumn("Id", this)
{
IsPrimaryKey = true,
DataType = DbType.Int32,
IsNullable = false,
AutoIncrement = true,
IsForeignKey = false,
MaxLength = 0
});
Columns.Add(new DatabaseColumn("Text", this)
{
IsPrimaryKey = false,
DataType = DbType.AnsiString,
IsNullable = false,
AutoIncrement = false,
IsForeignKey = false,
MaxLength = -1
});
Columns.Add(new DatabaseColumn("CreationDate", this)
{
IsPrimaryKey = false,
DataType = DbType.DateTime,
IsNullable = false,
AutoIncrement = false,
IsForeignKey = false,
MaxLength = 0
});
Columns.Add(new DatabaseColumn("LastChangeDate", this)
{
IsPrimaryKey = false,
DataType = DbType.DateTime,
IsNullable = false,
AutoIncrement = false,
IsForeignKey = false,
MaxLength = 0
});
Columns.Add(new DatabaseColumn("Counter1", this)
{
IsPrimaryKey = false,
DataType = DbType.Int32,
IsNullable = true,
AutoIncrement = false,
IsForeignKey = false,
MaxLength = 0
});
Columns.Add(new DatabaseColumn("Counter2", this)
{
IsPrimaryKey = false,
DataType = DbType.Int32,
IsNullable = true,
AutoIncrement = false,
IsForeignKey = false,
MaxLength = 0
});
Columns.Add(new DatabaseColumn("Counter3", this)
{
IsPrimaryKey = false,
DataType = DbType.Int32,
IsNullable = true,
AutoIncrement = false,
IsForeignKey = false,
MaxLength = 0
});
Columns.Add(new DatabaseColumn("Counter4", this)
{
IsPrimaryKey = false,
DataType = DbType.Int32,
IsNullable = true,
AutoIncrement = false,
IsForeignKey = false,
MaxLength = 0
});
Columns.Add(new DatabaseColumn("Counter5", this)
{
IsPrimaryKey = false,
DataType = DbType.Int32,
IsNullable = true,
AutoIncrement = false,
IsForeignKey = false,
MaxLength = 0
});
Columns.Add(new DatabaseColumn("Counter6", this)
{
IsPrimaryKey = false,
DataType = DbType.Int32,
IsNullable = true,
AutoIncrement = false,
IsForeignKey = false,
MaxLength = 0
});
Columns.Add(new DatabaseColumn("Counter7", this)
{
IsPrimaryKey = false,
DataType = DbType.Int32,
IsNullable = true,
AutoIncrement = false,
IsForeignKey = false,
MaxLength = 0
});
Columns.Add(new DatabaseColumn("Counter8", this)
{
IsPrimaryKey = false,
DataType = DbType.Int32,
IsNullable = true,
AutoIncrement = false,
IsForeignKey = false,
MaxLength = 0
});
Columns.Add(new DatabaseColumn("Counter9", this)
{
IsPrimaryKey = false,
DataType = DbType.Int32,
IsNullable = true,
AutoIncrement = false,
IsForeignKey = false,
MaxLength = 0
});
}
public IColumn Id{
get{
return this.GetColumn("Id");
}
}
public static string IdColumn{
get{
return "Id";
}
}
public IColumn Text{
get{
return this.GetColumn("Text");
}
}
public static string TextColumn{
get{
return "Text";
}
}
public IColumn CreationDate{
get{
return this.GetColumn("CreationDate");
}
}
public static string CreationDateColumn{
get{
return "CreationDate";
}
}
public IColumn LastChangeDate{
get{
return this.GetColumn("LastChangeDate");
}
}
public static string LastChangeDateColumn{
get{
return "LastChangeDate";
}
}
public IColumn Counter1{
get{
return this.GetColumn("Counter1");
}
}
public static string Counter1Column{
get{
return "Counter1";
}
}
public IColumn Counter2{
get{
return this.GetColumn("Counter2");
}
}
public static string Counter2Column{
get{
return "Counter2";
}
}
public IColumn Counter3{
get{
return this.GetColumn("Counter3");
}
}
public static string Counter3Column{
get{
return "Counter3";
}
}
public IColumn Counter4{
get{
return this.GetColumn("Counter4");
}
}
public static string Counter4Column{
get{
return "Counter4";
}
}
public IColumn Counter5{
get{
return this.GetColumn("Counter5");
}
}
public static string Counter5Column{
get{
return "Counter5";
}
}
public IColumn Counter6{
get{
return this.GetColumn("Counter6");
}
}
public static string Counter6Column{
get{
return "Counter6";
}
}
public IColumn Counter7{
get{
return this.GetColumn("Counter7");
}
}
public static string Counter7Column{
get{
return "Counter7";
}
}
public IColumn Counter8{
get{
return this.GetColumn("Counter8");
}
}
public static string Counter8Column{
get{
return "Counter8";
}
}
public IColumn Counter9{
get{
return this.GetColumn("Counter9");
}
}
public static string Counter9Column{
get{
return "Counter9";
}
}
}
}
\ No newline at end of file
<#@ template language="C#v3.5" debug="False" hostspecific="True" #>
<#@ output extension=".cs" #>
<#@ include file="SQLServer.ttinclude" #>
<#
var tables = LoadTables();
#>
using System;
using SubSonic.Schema;
using System.Collections.Generic;
using SubSonic.DataProviders;
using System.Data;
namespace <#=Namespace#> {
<# foreach(var tbl in tables){
if(!ExcludeTables.Contains(tbl.Name))
{
#>
/// <summary>
/// Table: <#=tbl.Name#>
/// Primary Key: <#=tbl.PrimaryKey#>
/// </summary>
public class <#=tbl.CleanName#>Table: DatabaseTable {
public <#=tbl.CleanName#>Table(IDataProvider provider):base("<#=tbl.Name#>",provider){
ClassName = "<#=tbl.ClassName#>";
SchemaName = "<#=tbl.Schema ?? ""#>";
<# foreach(var col in tbl.Columns){#>
Columns.Add(new DatabaseColumn("<#=col.Name#>", this)
{
IsPrimaryKey = <#=col.IsPK.ToString().ToLower()#>,
DataType = DbType.<#=col.DbType.ToString()#>,
IsNullable = <#=col.IsNullable.ToString().ToLower()#>,
AutoIncrement = <#=col.AutoIncrement.ToString().ToLower()#>,
IsForeignKey = <#=col.IsForeignKey.ToString().ToLower()#>,
MaxLength = <#=col.MaxLength#>
});
<# }#>
}
<# foreach(var col in tbl.Columns){#>
public IColumn <#=col.CleanName#>{
get{
return this.GetColumn("<#=col.Name#>");
}
}
public static string <#= col.CleanName #>Column{
get{
return "<#= col.Name #>";
}
}
<# }#>
}
<#
}
}
#>
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment