Skip to content

Commit

Permalink
Fix for T4 template where column names conflict with other methods/pr…
Browse files Browse the repository at this point in the history
…operties
  • Loading branch information
Brad Robinson committed Apr 26, 2011
1 parent 0dc8915 commit c8239ed
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
4 changes: 0 additions & 4 deletions PetaPoco.DevBed/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ namespace PetaPoco.DevBed

class Program
{

static void Main(string[] args)
{
var db = new PetaPoco.Database("mysql");

Console.WriteLine(db.SingleOrDefault<string>("SELECT title FROM articles WHERE article_id=@0", 270));
}
}
}
2 changes: 1 addition & 1 deletion PetaPoco.Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void CreateDB()
[TestFixtureTearDown]
public void DeleteDB()
{
//db.Execute(Utils.LoadTextResource(string.Format("PetaPoco.Tests.{0}_done.sql", _connectionStringName)));
db.Execute(Utils.LoadTextResource(string.Format("PetaPoco.Tests.{0}_done.sql", _connectionStringName)));
}

long GetRecordCount()
Expand Down
Binary file modified PetaPoco.Tests/petapoco.sdf
Binary file not shown.
20 changes: 10 additions & 10 deletions PetaPoco/Models/Generated/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ public class Record<T> where T:new()



[TableName("petapoco2")]
[PrimaryKey("email", autoIncrement=false)]
[ExplicitColumns]
public partial class petapoco2 : postgresqlDB.Record<petapoco2>
{
[Column] public string email { get; set; }
[Column] public string name { get; set; }
}


[TableName("petapoco")]
[PrimaryKey("id")]
[ExplicitColumns]
Expand All @@ -115,16 +125,6 @@ public partial class petapoco : postgresqlDB.Record<petapoco>
[Column("col w space")] public int? col_w_space { get; set; }
}


[TableName("petapoco2")]
[PrimaryKey("email", autoIncrement=false)]
[ExplicitColumns]
public partial class petapoco2 : postgresqlDB.Record<petapoco2>
{
[Column] public string email { get; set; }
[Column] public string name { get; set; }
}

}


9 changes: 9 additions & 0 deletions PetaPoco/Models/Generated/PetaPoco.Core.ttinclude
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,15 @@ Tables LoadTables()

conn.Close();

var rxClean = new Regex("^(Equals|GetHashCode|GetType|ToString|repo|Save|IsNew|Insert|Update|Delete|Exists|SingleOrDefault|Single|First|FirstOrDefault|Fetch|Page|Query)$");
foreach (var t in result)
{
foreach (var c in t.Columns)
{
c.PropertyName = rxClean.Replace(c.PropertyName, "_$1");
}
}

return result;
}
}
Expand Down

0 comments on commit c8239ed

Please sign in to comment.