当前位置导航:炫浪网>>网络学院>>网页制作>>ASP.NET教程

教你如何写codesmith模板(3)

  BLL层:

  <%@ CodeTemplate Language="C#" TargetLanguage="Text" Src="" Inherits="" Debug="False" Description="Template description here." %>

  <%@ Assembly Name="SchemaExplorer" %>

  <%@ Assembly Name="System.Data" %>

  <%@ Property Name="TargetTable" Type="SchemaExplorer.TableSchema" Category="Context"      Description="TargetTable that the object is based on." %>

  <%@ Property Name="Author" Type="System.String" Default="Xiao ChangJian"  Category="Context"  Description="The author for this procedure." %>

  <%@ Property Name="NameSpace" Type="System.String" Default="MySpace"  Category="Context"  Description="TargetTable that the object is based on." %>

  <%@ Property Name="Description" Type="System.String" Default="" Category="Context" Description="The description for this procedure."%>

  <%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>

  <%@ Import Namespace="SchemaExplorer" %>

  <%@ Import Namespace="System.Data" %>

  /* ----------------------------------------------------------------------

  * File Name: <%= GetTableName(TargetTable) %>Bll.cs

  *

  * Create Author: <%= Author %>

  *

  * Create DateTime: <%=DateTime.Now.ToShortDateString() %>

  *

  * Description: <%= Description %>

  *----------------------------------------------------------------------*/

  using System;

  using System.Collections;

  using System.Collections.Generic;

  using System.Text;

  namespace <%= NameSpace %>

  {

  public class <%= GetTableName(TargetTable) %>Bll

  {

  private static readonly <%= GetTableName(TargetTable) %>Bll _classinstance = new <%= GetTableName(TargetTable) %>Bll();

  public static <%= GetTableName(TargetTable) %>Bll ClassInstance {get{return _classinstance; }}

  /// <summary>

  /// Add Record

  /// </summary>

  public int Insert_<%= GetTableName(TargetTable) %>(<%= GetTableName(TargetTable) %>Model instance)

  {

  return <%= GetTableName(TargetTable) %>Dal.ClassInstance.Insert_<%= GetTableName(TargetTable) %>(instance);

  }

  /// <summary>

  /// Delete Record

  /// </summary>

  public int Delete_<%= GetTableName(TargetTable) %>(String pkid)

  {

  return <%= GetTableName(TargetTable) %>Dal.ClassInstance.Delete_<%= GetTableName(TargetTable) %>(pkid);

  }

  /// <summary>

  /// Update Record

  /// </summary>

  public int Update_<%= GetTableName(TargetTable) %>(<%= GetTableName(TargetTable) %>Model instance)

  {

  return <%= GetTableName(TargetTable) %>Dal.ClassInstance.Update_<%= GetTableName(TargetTable) %>(instance);

  }

相关内容
赞助商链接