OnceMi.AspNetCore.IdGenerator 1.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package OnceMi.AspNetCore.IdGenerator --version 1.0.4                
NuGet\Install-Package OnceMi.AspNetCore.IdGenerator -Version 1.0.4                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OnceMi.AspNetCore.IdGenerator" Version="1.0.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OnceMi.AspNetCore.IdGenerator --version 1.0.4                
#r "nuget: OnceMi.AspNetCore.IdGenerator, 1.0.4"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install OnceMi.AspNetCore.IdGenerator as a Cake Addin
#addin nuget:?package=OnceMi.AspNetCore.IdGenerator&version=1.0.4

// Install OnceMi.AspNetCore.IdGenerator as a Cake Tool
#tool nuget:?package=OnceMi.AspNetCore.IdGenerator&version=1.0.4                

OnceMi.AspNetCore.IdGenerator

ASP.NET Core雪花算法分布式ID生成工具。Use https://github.com/yitter/IdGenerator

How to use

1、Install OnceMi.AspNetCore.IdGenerator。
CLI中安装:

dotnet add package OnceMi.AspNetCore.IdGenerator

Nuget中安装:
在Nuget包管理器中搜索OnceMi.AspNetCore.IdGenerator并安装。

2、Configuration
You need to configure IdGenerator in your Startup.cs:

services.AddIdGenerator(x =>
{
    x.AppId = 1;   //Between 1-1023
});

在使用过程中保证每个IdGenerator一个AppId,Appid范围为1-1023。

3、Use

public class HomeController : Controller
{
    private readonly ILogger<HomeController> _logger;
    private readonly IIdGeneratorService _idGenerator;

    public HomeController(ILogger<HomeController> logger, IIdGeneratorService idGenerator)
    {
        _logger = logger;
        _idGenerator = idGenerator;
    }

    public IActionResult Index()
    {
        List<long> ids = new List<long>();
        for (int i = 0; i < 5; i++)
        {
            ids.Add(_idGenerator.NewId());
        }
        ViewBag.Ids = ids;
        return View();
    }
}

API Reference

NewId

long NewId();

生成一个ID。

NewIds

List<long> NewIds(int count);

生成指定个数的ID。

Features

Please visit https://github.com/yitter/IdGenerator

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on OnceMi.AspNetCore.IdGenerator:

Package Downloads
FBW.DotNet.AspNetCore

Package Description

BigHammer.Core.IdGenerator

Package Description

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on OnceMi.AspNetCore.IdGenerator:

Repository Stars
oncemi/OnceMi.Framework
基于.NET 7和Vue 2开发的企业级前后端分离权限管理开发框架(后台管理系统),具有组织管理、角色管理、用户管理、菜单管理、授权管理、计划任务、文件管理等功能。支持国内外多种流行数据库,支持IdentityServer4认证中心。
Version Downloads Last updated
1.0.6 9,041 10/20/2022
1.0.5 4,471 12/17/2021
1.0.4 499 6/21/2021