Skip to content

Commit

Permalink
@ prefix only works to escape keywords, it doesn't work for escaping …
Browse files Browse the repository at this point in the history
…digits so restore original approach of an underscore.
  • Loading branch information
tenbaset committed Dec 16, 2016
1 parent abe0cbc commit 09c255e
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 4 deletions.
Binary file modified Dapper.FastCrud.Tests/App_Data/EntityGenDatabase.mdf
Binary file not shown.
Binary file modified Dapper.FastCrud.Tests/App_Data/EntityGenDatabase_log.ldf
Binary file not shown.
63 changes: 60 additions & 3 deletions Dapper.FastCrud.Tests/Models/ModelGeneratorConfig1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
// Connection String Name: `EntityGeneration`
// Provider: `System.Data.SqlClient`
// Connection String: `Data Source=(LocalDb)\MSSQLLocalDb;AttachDbFilename=D:\_Projects\Dapper.FastCRUD\Dapper.FastCrud.Tests\App_Data\\EntityGenDatabase.mdf;Initial Catalog=EntityGenDatabase;Integrated Security=True`
// Connection String: `Data Source=(LocalDb)\MSSQLLocalDb;AttachDbFilename=c:\dev\Dapper.FastCRUD\Dapper.FastCrud.Tests\App_Data\\EntityGenDatabase.mdf;Initial Catalog=EntityGenDatabase;Integrated Security=True`
// Include Views: `True`

namespace Dapper.FastCrud.Tests.Models
Expand All @@ -17,41 +17,98 @@ namespace Dapper.FastCrud.Tests.Models
using System.Collections.Generic;

/// <summary>
/// A class which represents the Employee table.
/// Represents the CrazyColumns table.
/// </summary>
[Table("CrazyColumns")]
public partial class CrazyColumn
{
/// <summary>
/// Id Column
/// </summary>
[Key]
public virtual int Id { get; set; }
/// <summary>
/// Test starting with a digit
/// </summary>
public virtual int _123mb { get; set; }
/// <summary>
/// Test starting with a C# keyword
/// </summary>
public virtual int @switch { get; set; }
}

/// <summary>
/// Represents the Employee table.
/// </summary>
[Table("Employee")]
public partial class Employee
{
/// <summary>
/// UserId Column
/// </summary>
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public virtual int UserId { get; set; }
/// <summary>
/// EmployeeId Column
/// </summary>
[Key]
[Dapper.FastCrud.DatabaseGeneratedDefaultValue]
public virtual Guid EmployeeId { get; set; }
/// <summary>
/// KeyPass Column
/// </summary>
[Dapper.FastCrud.DatabaseGeneratedDefaultValue]
public virtual Guid KeyPass { get; set; }
/// <summary>
/// LastName Column
/// </summary>
public virtual string LastName { get; set; }
/// <summary>
/// FirstName Column
/// </summary>
public virtual string FirstName { get; set; }
/// <summary>
/// BirthDate Column
/// </summary>
public virtual DateTime BirthDate { get; set; }
/// <summary>
/// WorkstationId Column
/// </summary>
[ForeignKey("Workstation")]
public virtual long? WorkstationId { get; set; }
/// <summary>
/// FullName Column
/// </summary>
[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
public virtual string FullName { get; set; }
public virtual Workstation Workstation { get; set; }
}

/// <summary>
/// A class which represents the Workstations table.
/// Represents the Workstations table.
/// </summary>
[Table("Workstations")]
public partial class Workstation
{
/// <summary>
/// WorkstationId Column
/// </summary>
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public virtual long WorkstationId { get; set; }
/// <summary>
/// Name Column
/// </summary>
public virtual string Name { get; set; }
/// <summary>
/// AccessLevel Column
/// </summary>
[Dapper.FastCrud.DatabaseGeneratedDefaultValue]
public virtual int AccessLevel { get; set; }
/// <summary>
/// InventoryIndex Column
/// </summary>
public virtual int InventoryIndex { get; set; }
public virtual IEnumerable<Employee> Employees { get; set; }
}
Expand Down
3 changes: 2 additions & 1 deletion NuGetSpecs/GenericModelGenerator.tt
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,9 @@ static string[] cs_keywords = { "abstract", "event", "new", "struct", "as", "exp
static Func<string, string> CleanUp = (str) =>
{
str = rxCleanUp.Replace(str, "_");
if (char.IsDigit(str[0])) str = "_" + str;

if (char.IsDigit(str[0]) || cs_keywords.Contains(str))
if (cs_keywords.Contains(str))
str = "@" + str;

return str;
Expand Down

0 comments on commit 09c255e

Please sign in to comment.