zoukankan      html  css  js  c++  java
  • 动软生成仓储类

    <#@ template language="c#" HostSpecific="True" #>
    <#@ output extension= ".cs" #>
    <#
    TableHost host = (TableHost)(Host);
    host.Fieldlist.Sort(CodeCommon.CompareByintOrder);
    #>
    using Review.Core.Repositories.Dapper;
    using Review.Core.SOA;
    using Review.Permissions.Model;
    using System;
    using System.Collections.Generic;
    using System.Text;
    namespace Review.Permissions.Repositories
    {
    /// <summary>
    <# if( host.TableDescription.Length > 0) {#>
    /// <#= host.TableDescription #>
    <# } #>
    /// </summary>
    public class <#= host.GetModelClass(host.TableName) #>Rep
    {
    private readonly IDapperExtensionRepository<<#= host.GetModelClass(host.TableName) #>> _<#= host.GetModelClass(host.TableName).ToString().ToLower() #>;

    public <#= host.GetModelClass(host.TableName) #>Rep (IDapperExtensionRepository<<#= host.GetModelClass(host.TableName) #>> <#= host.GetModelClass(host.TableName).ToString().ToLower() #>)
    {
    _<#= host.GetModelClass(host.TableName).ToString().ToLower() #>=<#= host.GetModelClass(host.TableName).ToString().ToLower() #>;
    }

    /// <summary>
    <# if( host.TableDescription.Length > 0) {#>
    /// 获取<#= host.TableDescription #>数据
    <# } #>
    /// </summary>
    /// <param name="ID"></param>
    /// <returns></returns>
    public <#= host.GetModelClass(host.TableName) #> Find(long ID)
    {
    return _<#= host.GetModelClass(host.TableName).ToString().ToLower() #>.Find(i => i.<#= host.GetModelClass(host.TableName) #>ID == ID);
    }


    /// <summary>
    /// 添加
    /// </summary>
    /// <param name="model"></param>
    /// <returns></returns>
    public int Add(<#= host.GetModelClass(host.TableName) #> model)
    {
    return _<#= host.GetModelClass(host.TableName).ToString().ToLower() #>.InsertById(model);
    }

    /// <summary>
    /// 编辑
    /// </summary>
    /// <param name="model"></param>
    /// <returns></returns>
    public void Update(<#= host.GetModelClass(host.TableName) #> model)
    {
    _<#= host.GetModelClass(host.TableName).ToString().ToLower() #>.Update(model);
    }

    /// <summary>
    /// 获取列表
    /// </summary>
    /// <param name="page"></param>
    /// <returns></returns>
    public PageDataView<<#= host.GetModelClass(host.TableName) #>> Get<#= host.GetModelClass(host.TableName) #>InfoList(<#= host.GetModelClass(host.TableName) #> <#= host.GetModelClass(host.TableName).ToString().ToLower() #>, RequestPageBaseModel page)
    {
    PageCriteria pageCriteria = new PageCriteria();
    pageCriteria.TableName = "";
    pageCriteria.CurrentPage = page.CurrentPage;
    pageCriteria.PrimaryKey = "";
    pageCriteria.Fields = @"*";
    pageCriteria.Sort = page.Sorting.Replace(',', ' ').ToString();
    pageCriteria.PageSize = page.TotalPageCount;
    pageCriteria.Condition = "1=1";

    if (!string.IsNullOrEmpty(page.StartDateTime))
    {
    pageCriteria.Condition += string.Format(" AND a.CreateTime>='{0}'", page.StartDateTime);
    }
    if (!string.IsNullOrEmpty(page.EndDateTime))
    {
    pageCriteria.Condition += string.Format(" AND a.CreateTime<='{0}'", page.EndDateTime);
    }

    return _<#= host.GetModelClass(host.TableName).ToString().ToLower() #>.Page(pageCriteria);
    }
    }
    }

  • 相关阅读:
    1096 Consecutive Factors (20分)
    js-实现省市区地址选择器三级联动
    js-面向对象编程基础
    js-滑块拼图登录验证
    js-promise以及async、await实现简易红绿灯
    js-前端分页效果的实现
    js-ajax方法详解以及封装
    js-jsonp跨域请求原理以及jsonp的封装
    js-实现常见的拖拽效果(表单滑块验证)
    js本地存储-localStorage和cookie详解以及区别
  • 原文地址:https://www.cnblogs.com/tonglei/p/11266447.html
Copyright © 2011-2022 走看看