BLL-自动生成业务逻辑层代码

<%--
Name:
Author:
Description:
--%>
<%@ CodeTemplate Language="C#" TargetLanguage="Text" Src="" Inherits="" Debug="False" Description="Template description here." %>
<%@ Property Name="SampleStringProperty" Type="System.String" Default="SomeValue" Optional="True" Category="Strings" Description="This is a sample string property." %>
<%@ Property Name="SampleBooleanProperty" Type="System.Boolean" Default="True" Optional="False" Category="Booleans" Description="This is a sample boolean property." %>
<%@ Assembly Name="System.Data" %>
<%@ Import Namespace="System.Data" %>
<%@ Property Name="nameSpace" Type="String" Default="Eatery" Optional="False" Category="" Description="" OnChanged="" Editor="" EditorBase="" Serializer="" %>
<%@ Property Name="index" Type="System.int32" Default="0" Optional="False" Category="" Description="" OnChanged="" Editor="" EditorBase="" Serializer="" %>
<%@ Property Name="db" Type="SchemaExplorer.DatabaseSchema" Default="" Optional="False" Category="Context" Description="???" OnChanged="" Editor="" EditorBase="" Serializer="" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
<%@ Import Namespace="System.IO" %>
using System;
using System.Data.Common;
using System.Collections.Generic;
using System.Text;
using Model;
using <%=nameSpace %>DAL;

namespace <%=nameSpace %>BLL
{
 public class <%=GetClassName() %>BLL
 {
  private <%=GetClassName() %>DAL <%=GetObjectName() %>DAL = new <%=GetClassName() %>DAL();
  
  public int Add(<%=GetClassName() %> <%=GetObjectName() %>)
        {
            return <%=GetObjectName() %>DAL.Add(<%=GetObjectName() %>);
        }
  
  public int AddReturn<%=StringUtil.ToPascalCase(db.Tables[index].Columns[0].Name) %>(<%=GetClassName() %> <%=GetObjectName() %>)
        {
            return <%=GetObjectName() %>DAL.AddReturn<%=StringUtil.ToPascalCase(db.Tables[index].Columns[0].Name) %>(<%=GetObjectName() %>);
        }
  
  public int Update(<%=GetClassName() %> <%=GetObjectName() %>)
  {
   return <%=GetObjectName() %>DAL.Update(<%=GetObjectName() %>);
  }
  
  public int Delete(int <%=StringUtil.ToCamelCase(GetPrimaryKey()) %>)
  {
   return <%=GetObjectName() %>DAL.Delete(<%=StringUtil.ToCamelCase(GetPrimaryKey()) %>);
  }
 
  public List<<%=GetClassName() %>> GetAll()
  {
   return <%=GetObjectName() %>DAL.GetAll();
  }
  
  public <%=GetClassName() %> GetSingle(int <%=StringUtil.ToCamelCase(GetPrimaryKey()) %>)
        {
            return <%=GetObjectName() %>DAL.GetSingle(<%=StringUtil.ToCamelCase(GetPrimaryKey()) %>);
  }
  
  public List<<%=GetClassName() %>> GetAllByConditions(string conditions)
  {
   return <%=GetObjectName() %>DAL.GetAllByConditions(conditions);
  }
 }
}
<script runat="template">
 public string GetClassName()
 {
  return StringUtil.ToPascalCase(db.Tables[index].Name);
 }
 public string GetObjectName()
 {
  return StringUtil.ToCamelCase(db.Tables[index].Name); 
 }
 public string GetPrimaryKey()
 {
  return db.Tables[index].Columns[0].Name ; 
 }
 public override void Render(TextWriter writer)
 {
  string path1 =OutputDirectory + GetClassName()  + "BLL.cs";
  System.Diagnostics.Trace.WriteLine(path1);
  StreamWriter fileWriter1 = new StreamWriter(path1,false);
  this.Response.AddTextWriter(fileWriter1);
  base.Render(writer);
  fileWriter1.Close();
 }
 private string _outputDirectory = String.Empty;

 [Editor(typeof(System.Windows.Forms.Design.FolderNameEditor), typeof(System.Drawing.Design.UITypeEditor))]
 [Optional]
 [Category("Output")]
 [Description("The directory to output the results to.")]
 public string OutputDirectory
 {
  get
  {
    // default to the directory that the template is located in
    if (_outputDirectory.Length == 0) return this.CodeTemplateInfo.DirectoryName;
 
    return _outputDirectory;
  }
  set
  {
    if (!value.EndsWith("//")) value += "//";
    _outputDirectory = value;
  }
 }
</script>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值