Skip to content

Commit

Permalink
Fix for issue 19 - allow different primary key types such as long
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenWalther committed Mar 13, 2014
1 parent 184a9a8 commit 922c5a8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions WebFormsScaffolding/Scaffolders/WebFormsScaffolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ private void AddWebFormsViewTemplates(CodeType modelType,
{"PrimarySectionName", primarySectionName},
{"PrimaryKeyMetadata", primaryKey},
{"PrimaryKeyName", primaryKey.PropertyName},
{"PrimaryKeyType", primaryKey.ShortTypeName},
{"ViewDataType", modelType},
{"ViewDataTypeName", modelType.Name},
{"DBContextType", dbContext.Name},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<#@ parameter type="System.Array" name="SectionNames" #>
<#@ parameter type="System.String" name="PrimarySectionName" #>
<#@ parameter type="System.String" name="PrimaryKeyName" #>
<#@ parameter type="System.String" name="PrimaryKeyType" #>
<#@ parameter type="System.MarshalByRefObject" name="ViewDataType" #>
<#@ parameter type="System.String" name="ViewDataTypeName" #>
<#@ parameter type="System.String" name="DBContextType" #>
Expand Down Expand Up @@ -52,7 +53,7 @@ namespace <#= DefaultNamespace #>

// This is the Delete methd to delete the selected <#=ViewDataTypeName#> item
// USAGE: <asp:FormView DeleteMethod="DeleteItem">
public void DeleteItem(int <#= PrimaryKeyName #>)
public void DeleteItem(<#= PrimaryKeyType #> <#= PrimaryKeyName #>)
{
using (var context = new <#= DBContextType #>())
{
Expand All @@ -69,7 +70,7 @@ namespace <#= DefaultNamespace #>

// This is the Select methd to selects a single <#=ViewDataTypeName#> item with the id
// USAGE: <asp:FormView SelectMethod="GetItem">
public <#= fullModelName#> GetItem([QueryString]int? <#= PrimaryKeyName #>)
public <#= fullModelName#> GetItem([QueryString]<#= PrimaryKeyType #> ? <#= PrimaryKeyName #>)
{
if (<#= PrimaryKeyName #> == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<#@ parameter type="System.Array" name="SectionNames" #>
<#@ parameter type="System.String" name="PrimarySectionName" #>
<#@ parameter type="System.String" name="PrimaryKeyName" #>
<#@ parameter type="System.String" name="PrimaryKeyType" #>
<#@ parameter type="System.MarshalByRefObject" name="ViewDataType" #>
<#@ parameter type="System.String" name="ViewDataTypeName" #>
<#@ parameter type="System.String" name="DBContextType" #>
Expand Down Expand Up @@ -52,7 +53,7 @@ namespace <#= DefaultNamespace #>

// This is the Update methd to update the selected <#=ViewDataTypeName#> item
// USAGE: <asp:FormView UpdateMethod="UpdateItem">
public void UpdateItem(int <#= PrimaryKeyName #>)
public void UpdateItem(<#= PrimaryKeyType #> <#= PrimaryKeyName #>)
{
using (var context = new <#= DBContextType #>())
{
Expand All @@ -78,7 +79,7 @@ namespace <#= DefaultNamespace #>

// This is the Select method to selects a single <#=ViewDataTypeName#> item with the id
// USAGE: <asp:FormView SelectMethod="GetItem">
public <#=fullModelName#> GetItem([QueryString]int? <#= PrimaryKeyName #>)
public <#=fullModelName#> GetItem([QueryString]<#= PrimaryKeyType #> ? <#= PrimaryKeyName #>)
{
if (<#= PrimaryKeyName #> == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<#@ parameter type="System.Array" name="SectionNames" #>
<#@ parameter type="System.String" name="PrimarySectionName" #>
<#@ parameter type="System.String" name="PrimaryKeyName" #>
<#@ parameter type="System.String" name="PrimaryKeyType" #>
<#@ parameter type="System.MarshalByRefObject" name="ViewDataType" #>
<#@ parameter type="System.String" name="ViewDataTypeName" #>
<#@ parameter type="System.String" name="DBContextType" #>
Expand Down

0 comments on commit 922c5a8

Please sign in to comment.