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

  • 相关阅读:
    Codeforces Round #646 (Div. 2) B. Subsequence Hate(前缀和/思维)
    Codeforces Round #646 (Div. 2) A. Odd Selection(思维/分类讨论)
    “科林明伦杯”哈尔滨理工大学第十届程序设计竞赛 A.点对最大值(树的直径/树形DP)
    “科林明伦杯”哈尔滨理工大学第十届程序设计竞赛(同步赛)(ABCEFHJ)
    Codeforces Round #645 (Div. 2) C. Celex Update(思维)
    Codeforces Round #645 (Div. 2) D. The Best Vacation(二分+前缀和)
    Codeforces Round #645 (Div. 2) B. Maria Breaks the Self-isolation(贪心)
    Codeforces Round #645 (Div. 2) A. Park Lighting
    ORM之SQLALchemy
    python--10--mysql(2)
  • 原文地址:https://www.cnblogs.com/tonglei/p/11266447.html
Copyright © 2011-2022 走看看