1 Star 0 Fork 0

Niubility/Database

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

### Install NuGet Package

> dotnet add package Niubility.Database

Create entity class file

using Niubility.Database.Entity;

namespace {YourProject}
{
    [Table("dbo", "SystemConfigurations")]
    public class SystemConfigurations
    {
        [Column(false, false, false, true, 200, null, 1, null)]
        public string Key { get; set; }
        [Column(false, false, false, false, 2000, null, 2, null)]
        public string Value { get; set; }
    }
}

Create repository class file

using Niubility.Database;

namespace {YourProject}
{
    private class SystemConfigurationRepository : NiubilityRepository<SystemConfigurations>
    {
        public SystemConfigurationRepository(IDatabaseConnectionManager connectionManager)
            : base(connectionManager)
        { }

        ...append your methods here
    }
}

Then, you can easily CRUD for your tables

var repository = new SystemConfigurationRepository(connectionManager);
//// get all rows
repository.SelectEntities(connection, transaction);
//// get data row by key
repository.SelectEntityByPrimaryKey(key, connection, transaction);
//// get rows matched keys
repository.SelectEntitiesByPrimaryKeys(keys, connection, transaction);
//// insert or update entity
repository.InsertOrUpdateEntity(entity, connection, transaction);
//// insert or update entities
repository.InsertOrUpdateEntities(entities, connection, transaction);
//// delete data row by key
repository.DeleteEntityByPrimaryKey(key, connection, transaction);
//// delete rows matched keys
repository.DeleteEntitiesByPrimaryKeys(keys, connection, transaction);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/niubility10086/database.git
git@gitee.com:niubility10086/database.git
niubility10086
database
Database
master

搜索帮助