• 动软生成仓储类


    <#@ 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);
    }
    }
    }

  • 相关阅读:
    如何区分DDR1 DDR2 DDR3内存条
    《闪电战》德军攻略
    WINDOWS SERVER 2008 R2安装指南
    【django】django学得好迷茫啊 来个学习规划吧
    【阅读】提问的智慧+有效的报告BUG
    【Python】logging模块学习笔记
    【接口测试】进度表
    【django】django深入学习笔记
    【随笔】2014工作总结
    【英语】Bingo口语笔记(47)
  • 原文地址:https://www.cnblogs.com/tonglei/p/11266447.html
Copyright © 2020-2023  润新知