zoukankan      html  css  js  c++  java
  • MicroOrm.Dapper.Repositories 的使用

    https://github.com/geffzhang/MicroOrm.Dapper.Repositories

    1、特性标记都是要引用: System.ComponentModel.DataAnnotations

    特性有这么一些: 

    [Key]
    从system.componentmodel.dataannotations
    [Table]
    从system.componentmodel.dataannotations.schema -默认数据库表的名称将模型名称匹配但可以重写这个。
    [Column]
    从system.componentmodel.dataannotations.schema -默认列名称属性名称匹配但可以重写这个。
    [NotMapped]

    从system.componentmodel.dataannotations.schema -“逻辑”的属性,没有相应的栏目,必须由SQL生成器忽略。
    [Status]
    对于实现“逻辑删除”而不是物理删除的表。这个属性可以装饰只枚举属性和一个值的枚举来装饰的“删除”属性。
    [Deleted]
    前属性兄弟。使用这种装饰的枚举值指定逻辑删除状态属性值。
    [Identity
    ]  

    用于身份密钥。  标识  自增等id

    第一步:创建一个类:

    第二步:创建一个仓储(可以对应创建一些接口)

    public class CredentiaRepository:DapperRepository<Credential>,IDalCredential
    {
    public CredentiaRepository(IDbConnection connection, ISqlGenerator<Credential> sqlGenerator)
    : base(connection, sqlGenerator)
    {

    }
    //下面实现redis的操作

    }

    第三步:具体的实现 使用方法

    bool Delete(TEntity instance);
    
        Task<bool> DeleteAsync(TEntity instance);
    
        TEntity Find(Expression<Func<TEntity, bool>> expression);
    
        IEnumerable<TEntity> FindAll();
    
        IEnumerable<TEntity> FindAll(Expression<Func<TEntity, bool>> expression);
    
        Task<IEnumerable<TEntity>> FindAllAsync();
    
        Task<IEnumerable<TEntity>> FindAllAsync(Expression<Func<TEntity, bool>> expression);
    
        Task<TEntity> FindAsync(Expression<Func<TEntity, bool>> expression);
    
        bool Insert(TEntity instance);
    
        Task<bool> InsertAsync(TEntity instance);
    
        bool Update(TEntity instance);
    
        Task<bool> UpdateAsync(TEntity instance);
    第四步 调用:

  • 相关阅读:
    方维o2o系统域名绑定破解详解
    smarty 学习笔记一
    手机禁止缩放网页 手机CSS导入
    Android 学习笔记(一)
    自动填充短信验证码(使用ContentObserver)
    分享100个开源android项目源码
    php如何实现验证码
    Zend Studio 13 v13.0.0汉化中文版
    java中的静态方法
    继承代码
  • 原文地址:https://www.cnblogs.com/zxs-onestar/p/6400832.html
Copyright © 2011-2022 走看看