Giter Club home page Giter Club logo

abp.extensions's Introduction

Abp.Extension.Orm.Dapper

thanks Abp.Dapper,Dapper,DapperExtensions

how to use!

  1. DependsOn
[DependsOn(typeof(OrmDapperModule))]
public class AbpZeroTemplateWebCoreModule : AbpModule
  1. init database connectionString open file Startup.cs
 public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory){
    	app.UseOrmDapper(connectionString);
    }
  1. Use Repository
private readonly IDapperRepository<User, long> _useDapperRepository;
//1 use sql 
var output = (await _useDapperRepository.QueryAsync<User>("select * from AbpUsers")).ToList();
//2 no sql
var output = (await _useDapperRepository.GetListAsync<User>()).ToList();
//3 use uow
using (var uow = _useDapperRepository.Begin())
{
	var output = (await _useDapperRepository.QueryAsync<User>("select * from AbpUsers")).ToList();	
	uow.Dispose();
}

Abp.Extension.Background

  1. 引用dll
Install-Package Abp.Extension.Background
  1. 添加任务类
public class TestTask : IHTask
    {

        public ILogger Logger { get; set; }
        public TestTask()
        {
            Logger = IocManager.Instance.Resolve<ILogger>();
        }

        public void Run()
        {
            Logger.Debug("测试任务执行.............");
        }

        public string Cron()
        {
            return Hangfire.Cron.Minutely();
        }
    }
  1. 注册任务类
//依赖
[DependsOn(typeof(AbpBackgroundModule))]
//注册
public override void PostInitialize()
        {
            
            var queue = IocManager.Resolve<BackTaskQueue>();
            queue.Add(typeof(TestTask).FullName, typeof(TestTask));

        }
  1. Host项目startUp 启用hangfire
//a. ConfigureServices方法
services.AddHangfire(config =>
            {                
                config.UseMemoryStorage();
            });
//b.Configure方法
//app.UseHangfireDashboard("/hangfire", new DashboardOptions
  //          {
    //            Authorization = new[] { new AbpHangfireAuthorizationFilter(AppPermissions.Pages_Administration_HangfireDashboard) }
      //      });
app.UseHangfireServer();
//****
app.RunHangfireTask();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.