OnceMi.AspNetCore.IdGenerator 1.0.5

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.5
NuGet\Install-Package OnceMi.AspNetCore.IdGenerator -Version 1.0.5
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.5" />
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.5
#r "nuget: OnceMi.AspNetCore.IdGenerator, 1.0.5"
#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.5

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

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中安装: alternate text is missing from this package README image

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

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

    在使用过程中保证每个IdGenerator一个AppId,Appid范围为0-63,如果超过64个应用,可自定义Option(默认Option WorkId为6位)。

  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

long[] NewIds(int count);

生成指定个数的ID。

Features

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

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

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 7,744 10/20/2022
1.0.5 4,412 12/17/2021
1.0.4 471 6/21/2021