国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

第1章 獲取數(shù)據(jù)庫中的數(shù)據(jù)

這篇具有很好參考價值的文章主要介紹了第1章 獲取數(shù)據(jù)庫中的數(shù)據(jù)。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報違法"按鈕提交疑問。

??? CoreShop源程序是以數(shù)據(jù)庫優(yōu)先進(jìn)行定義的,所以其本身不包含代碼優(yōu)先的定義,但本從更習(xí)慣于代碼優(yōu)先,所以為其定義了代碼優(yōu)先的定義。

1 CoreCms.Net.Model.Entities.SysRole

using SqlSugar;

using System.ComponentModel.DataAnnotations;

namespace CoreCms.Net.Model.Entities

{

? ? /// <summary>

? ? /// 【系統(tǒng)角色--類】

? ? /// <remarks>

? ? /// 摘要:

? ? /// ? ? 通過該實體類及其屬性成員,用于實現(xiàn)當(dāng)前程序【CoreCms.Net.Model.【實體集】.SysRole】實體與“[CoreShop230628].[SysRole]”表之間的CURD的交互操作,并把這些數(shù)據(jù)存儲到數(shù)據(jù)庫設(shè)置實例中(內(nèi)存)

? ? /// </remarks>

? ? /// </summary>

? ? [SugarTable("SysRole", TableDescription = "角色表")]

? ? public class SysRole

? ? {

? ? ? ? /// <summary>

? ? ? ? /// 【角色編號】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置系統(tǒng)角色實體1個指定實例的整型編號值。

? ? ? ? /// IsPrimaryKey:主鍵

? ? ? ? /// IsIdentit:自增

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "角色編號")]

? ? ? ? [SugarColumn(ColumnDescription = "角色編號", IsPrimaryKey = true, IsIdentity = true)]

? ? ? ? [Required(ErrorMessage = "請輸入{0}")]

? ? ? ? public int Id { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【角色名稱】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置1個指定系統(tǒng)角色的名稱。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "角色名稱")]

? ? ? ? [SugarColumn(ColumnDescription = "角色名稱", ColumnDataType = "nvarchar", Length = 50)]

? ? ? ? [Required(ErrorMessage = "請輸入{0}")]

? ? ? ? [StringLength(50, ErrorMessage = "{0}】不能超過{1}字符長度")]

? ? ? ? public string RoleName { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【角色名稱】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置1個指定系統(tǒng)角色的標(biāo)識。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "角色標(biāo)識")]

? ? ? ? [SugarColumn(ColumnDescription = "角色標(biāo)識", ColumnDataType = "nvarchar", Length = 50, IsNullable = true)]

? ? ? ? [StringLength(50, ErrorMessage = "{0}】不能超過{1}字符長度")]

? ? ? ? public string RoleCode { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【角色名稱】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置1個指定系統(tǒng)角色的備注。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "備注")]

? ? ? ? [SugarColumn(ColumnDescription = "備注", ?ColumnDataType = "nvarchar", Length = 255, IsNullable = true)]

? ? ? ? [StringLength(255, ErrorMessage = "{0}】不能超過{1}字符長度")]

? ? ? ? public string Comments { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【邏輯刪除?】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置1個值false(可用=0)/true(已經(jīng)被邏輯刪除=1),該值指示系統(tǒng)角色實體的1個指定實例是否已經(jīng)處于邏輯刪除狀態(tài)。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "是否刪除,0,1")]

? ? ? ? [SugarColumn(ColumnDescription = "是否刪除,0,1")]

? ? ? ? [Required(ErrorMessage = "請輸入{0}")]

? ? ? ? public bool Deleted { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【創(chuàng)建時間】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置系統(tǒng)角色實體1個指定實例第1次被持久化到系統(tǒng)角色表中的時間。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "創(chuàng)建時間")]

? ? ? ? [SugarColumn(ColumnDescription = "創(chuàng)建時間")]

? ? ? ? [Required(ErrorMessage = "請輸入{0}")]

? ? ? ? public DateTime CreateTime { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【修改時間】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置系統(tǒng)角色1個指定實例最后1次被修改后,持久化到系統(tǒng)角色表中的時間。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "修改時間")]

? ? ? ? [SugarColumn(ColumnDescription = "修改時間")]

? ? ? ? public DateTime UpdateTime { get; set; }

? ? }

}

2 CoreCms.Net.Model.Entities.SysUser

using SqlSugar;

using System.ComponentModel.DataAnnotations;

namespace CoreCms.Net.Model.Entities

{

? ? /// <summary>

? ? /// 【系統(tǒng)用戶--類】

? ? /// <remarks>

? ? /// 摘要:

? ? /// ? ? 通過該實體類及其屬性成員,用于實現(xiàn)當(dāng)前程序【CoreCms.Net.Model.【實體集】.SysUser】實體與“[CoreShop230628].[SysUser]”表之間的CURD的交互操作,并把這些數(shù)據(jù)存儲到數(shù)據(jù)庫設(shè)置實例中(內(nèi)存)。

? ? /// </remarks>

? ? /// </summary>

? ? [SugarTable("SysUser", TableDescription = "用戶表")]

? ? public partial class SysUser

? ? {

? ? ? ? /// <summary>

? ? ? ? /// 【系統(tǒng)用戶色編號】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置系統(tǒng)角色實體1個指定實例的整型編號值。

? ? ? ? /// IsPrimaryKey:主鍵

? ? ? ? /// IsIdentit:自增

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "用戶id")]

? ? ? ? [SugarColumn(ColumnDescription = "用戶id", IsPrimaryKey = true, IsIdentity = true)]

? ? ? ? [Required(ErrorMessage = "請輸入{0}")]

? ? ? ? public int Id { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【賬號】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置1個指定系統(tǒng)用戶的賬號名稱。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "賬號")]

? ? ? ? [SugarColumn(ColumnDescription = "賬號", ColumnDataType = "nvarchar", Length = 50, IsNullable = true)]

? ? ? ? [StringLength(50, ErrorMessage = "{0}】不能超過{1}字符長度")]

? ? ? ? public string UserName { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【密碼】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置1個指定系統(tǒng)用戶的登錄密碼。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "密碼")]

? ? ? ? [SugarColumn(ColumnDescription = "密碼", ColumnDataType = "nvarchar", Length = 100, IsNullable = true)]

? ? ? ? [StringLength(100, ErrorMessage = "{0}】不能超過{1}字符長度")]

? ? ? ? public string PassWord { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【昵稱】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置1個指定系統(tǒng)用戶的昵稱。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "昵稱")]

? ? ? ? [SugarColumn(ColumnDescription = "昵稱", ColumnDataType = "nvarchar", Length = 50, IsNullable = true)]

? ? ? ? [StringLength(50, ErrorMessage = "{0}】不能超過{1}字符長度")]

? ? ? ? public string NickName { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【昵稱】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置1個指定系統(tǒng)用戶的頭像。

? ? ? ? /// 說明:

? ? ? ? /// ? ? 該屬性通過網(wǎng)絡(luò)格式的絕/相對路徑來映射用戶頭像圖片。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "頭像")]

? ? ? ? [SugarColumn(ColumnDescription = "頭像", ColumnDataType = "nvarchar", Length = 255, IsNullable = true)]

? ? ? ? [StringLength(255, ErrorMessage = "{0}】不能超過{1}字符長度")]

? ? ? ? public string Avatar { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【性別】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置1個指定系統(tǒng)用戶的性別。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "性別")]

? ? ? ? [SugarColumn(ColumnDescription = "性別")]

? ? ? ? [Required(ErrorMessage = "請輸入{0}")]

? ? ? ? public int Sex { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【手機(jī)號】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置1個指定系統(tǒng)用戶的手機(jī)號。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "手機(jī)號")]

? ? ? ? [SugarColumn(ColumnDescription = "手機(jī)號", ColumnDataType = "nvarchar", Length = 50, IsNullable = true)]

? ? ? ? [StringLength(50, ErrorMessage = "{0}】不能超過{1}字符長度")]

? ? ? ? public string Phone { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【郵箱】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置1個指定系統(tǒng)用戶的郵箱。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "郵箱")]

? ? ? ? [SugarColumn(ColumnDescription = "郵箱", ColumnDataType = "nvarchar", Length = 50, IsNullable = true)]

? ? ? ? [StringLength(50, ErrorMessage = "{0}】不能超過{1}字符長度")]

? ? ? ? public string Email { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【郵箱驗證?】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置1個值false(不需要)/true(需要),該值指示1個指定系統(tǒng)用戶是否需要在郵箱驗證操作后才能執(zhí)行登錄操作。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "郵箱是否驗證")]

? ? ? ? [SugarColumn(ColumnDescription = "郵箱是否驗證")]

? ? ? ? [Required(ErrorMessage = "請輸入{0}")]

? ? ? ? public bool EmailVerified { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【實名】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置1個指定系統(tǒng)用戶的實名。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "真實姓名")]

? ? ? ? [SugarColumn(ColumnDescription = "真實姓名", ColumnDataType = "nvarchar", Length = 50, IsNullable = true)]

? ? ? ? [StringLength(50, ErrorMessage = "{0}】不能超過{1}字符長度")]

? ? ? ? public string TrueName { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【身份證號】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置1個指定系統(tǒng)用戶的身份證號。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "身份證號")]

? ? ? ? [SugarColumn(ColumnDescription = "身份證號", ColumnDataType = "nvarchar", Length = 50, IsNullable = true)]

? ? ? ? [StringLength(50, ErrorMessage = "{0}】不能超過{1}字符長度")]

? ? ? ? public string IdCard { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【出生日期】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置1個指定系統(tǒng)用戶的生日。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "出生日期")]

? ? ? ? [SugarColumn(ColumnDescription = "出生日期", IsNullable = true)]

? ? ? ? public DateTime? Birthday { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【個人簡介】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置1個指定系統(tǒng)用戶的個人簡介。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "個人簡介")]

? ? ? ? [SugarColumn(ColumnDescription = "個人簡介", ColumnDataType = "nvarchar", Length = 500, IsNullable = true)]

? ? ? ? [StringLength(500, ErrorMessage = "{0}】不能超過{1}字符長度")]

? ? ? ? public string Introduction { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【機(jī)構(gòu)編號】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置1個指定系統(tǒng)用戶的機(jī)構(gòu)編號。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "機(jī)構(gòu)id")]

? ? ? ? [SugarColumn(ColumnDescription = "機(jī)構(gòu)id", IsNullable = true)]

? ? ? ? public int? OrganizationId { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【狀態(tài)】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置1個值0(正常)/1 (凍結(jié)),該值指示1個指定系統(tǒng)用戶是否需要在郵箱驗證操作后才能執(zhí)行登錄操作。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "狀態(tài),0正常,1凍結(jié)")]

? ? ? ? [SugarColumn(ColumnDescription = "狀態(tài),0正常,1凍結(jié)")]

? ? ? ? [Required(ErrorMessage = "請輸入{0}")]

? ? ? ? public int State { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【邏輯刪除?】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置1個值false(可用=0)/true(已經(jīng)被邏輯刪除=1),該值指示系統(tǒng)用戶實體的1個指定實例是否已經(jīng)處于邏輯刪除狀態(tài)。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "是否刪除,0,1")]

? ? ? ? [SugarColumn(ColumnDescription = "是否刪除,0,1")]

? ? ? ? [Required(ErrorMessage = "請輸入{0}")]

? ? ? ? public bool Deleted { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【注冊時間】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置系統(tǒng)用戶實體1個指定實例第1次被持久化到系統(tǒng)用戶表中的時間。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "注冊時間")]

? ? ? ? [SugarColumn(ColumnDescription = "注冊時間")]

? ? ? ? [Required(ErrorMessage = "請輸入{0}")]

? ? ? ? public DateTime CreateTime { get; set; }

? ? ? ? /// <summary>

? ? ? ? /// 【修改時間】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 獲取/設(shè)置系統(tǒng)用戶1個指定實例最后1次被修改后,持久化到系統(tǒng)角色表中的時間。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? [Display(Name = "修改時間")]

? ? ? ? [SugarColumn(ColumnDescription = "修改時間", IsNullable = true)]

? ? ? ? public DateTime UpdateTime { get; set; }

? ? }

}

3 CoreCms.Net.Core.Config.SqlSugarSetup

using Microsoft.Extensions.DependencyInjection;

using SqlSugar;

using SqlSugar.IOC; ? ? ? ? ? ? ? ? ?

using System.Reflection;

namespace CoreCms.Net.Core.Config

{

? ? /// <summary>

? ? /// SqlSugarCore中間件啟動--類】

? ? /// <remarks>

? ? /// 摘要:

? ? /// ? ? 通過該類中的方法成員,把SqlSugarCore中間件依賴注入到.Net(Core)框架內(nèi)置依賴注入容器中。

? ? /// </remarks>

? ? /// </summary>

? ? public static class SqlSugarSetup

? ? {

? ? ? ? /// <param name="services">.Net(Core)框架內(nèi)置依賴注入容器實例。</param>

? ? ? ? /// <summary>

? ? ? ? /// 【配置服務(wù)】

? ? ? ? /// <remarks>

? ? ? ? /// 摘要:

? ? ? ? /// ? ? 通過該方法成員,把SqlSugarCore中間件依賴注入到.Net(Core)框架內(nèi)置依賴注入容器中。。

? ? ? ? /// </remarks>

? ? ? ? /// </summary>

? ? ? ? public static void AddSqlSugarSetup(this IServiceCollection services)

? ? ? ? {

? ? ? ? ? ? if (services == null) throw new ArgumentNullException(nameof(services));

? ? ? ? ? ? //注入 ORM

? ? ? ? ? ? SugarIocServices.AddSqlSugar(new IocConfig()

? ? ? ? ? ? {

? ? ? ? ? ? ? ? //數(shù)據(jù)庫連接

? ? ? ? ? ? ? ? /*ConnectionString = AppSettingsConstVars.DbSqlConnection,

? ? ? ? ? ? ? ? //判斷數(shù)據(jù)庫類型

? ? ? ? ? ? ? ? DbType = AppSettingsConstVars.DbDbType == IocDbType.MySql.ToString() ? IocDbType.MySql : IocDbType.SqlServer,*/

? ? ? ? ? ? ? ? ConnectionString = "Server=.;uid=zz;pwd=zz;Database=CoreShop230628;MultipleActiveResultSets=true;pooling=true;min pool size=5;max pool size=32767;connect timeout=20;Encrypt=True;TrustServerCertificate=True;",

? ? ? ? ? ? ? ? DbType = IocDbType.SqlServer,

? ? ? ? ? ? ? ? //是否開啟自動關(guān)閉數(shù)據(jù)庫連接-//不設(shè)成true要手動close

? ? ? ? ? ? ? ? IsAutoCloseConnection = true,

? ? ? ? ? ? });

? ? ? ? ? ? //設(shè)置參數(shù)

? ? ? ? ? ? services.ConfigurationSugar(db =>

? ? ? ? ? ? {

? ? ? ? ? ? ? ? db.CurrentConnectionConfig.InitKeyType = InitKeyType.Attribute;

? ? ? ? ? ? ? ? //說明:CoreShop的程序是數(shù)據(jù)庫優(yōu)先,即必須先生成指定的數(shù)據(jù)庫,本人更為喜歡代碼優(yōu)先所以進(jìn)行了以下定義來實現(xiàn)代碼優(yōu)先。

? ? ? ? ? ? ? ? //如果指定的數(shù)據(jù)庫軟件中不存在指定的數(shù)據(jù)庫,則自動生成該數(shù)據(jù)庫。

? ? ? ? ? ? ? ? db.DbMaintenance.CreateDatabase();

? ? ? ? ? ? ? ? //通過反射操作,獲取領(lǐng)域文件夾中的所有實體的類型實例。

? ? ? ? ? ? ? ? //直接獲取指定項目中所有類的類型實例。

? ? ? ? ? ? ? ? Assembly assembly = Assembly.Load("CoreCms.Net.Model");

? ? ? ? ? ? ? ? //通過過濾操作,獲取領(lǐng)域文件夾中的所有實體的類型實例。

? ? ? ? ? ? ? ? //注意:“Where”過濾操作中“ c.Namespace”最好使用“Contains”,而不要使用“==”。

? ? ? ? ? ? ? ? Type[] _typeArray = assembly.GetTypes()

? ? ? ? ? ? ? ? ? ? .Where(c => c.Namespace.Contains("CoreCms.Net.Model.Entities") && c.IsClass)//過濾操作。

? ? ? ? ? ? ? ? ? ? .ToArray();

? ? ? ? ? ? ? ? //如果數(shù)據(jù)庫軟件對自動生成的數(shù)據(jù)庫支持自動備份操作,則通過下行語句在自動生成該數(shù)據(jù)庫中,根據(jù)當(dāng)前項目中的實體類自動生成相應(yīng)的表。

? ? ? ? ? ? ? ? //注意:SetStringDefaultLength(stringDefaultLength)必須定義在下行語句中,否則在自動生成表時,該約束定義將不會被映射到表的字段上。

? ? ? ? ? ? ? ? db.CodeFirst.SetStringDefaultLength(50).BackupTable().InitTables(_typeArray);

? ? ? ? ? ? });

? ? ? ? }

? ? }

}

4 Program.cs

using CoreCms.Net.Core.Config;

var builder = WebApplication.CreateBuilder(args);

//添加數(shù)據(jù)庫連接SqlSugar注入支持

builder.Services.AddSqlSugarSetup();

5 CoreCms.Net.Web.Admin.Controllers.SysRoleController

using Microsoft.AspNetCore.Mvc;

using System.ComponentModel;

using SqlSugar;

using SqlSugar.IOC;

using CoreCms.Net.Model.Entities;

namespace CoreCms.Net.Web.Admin.Controllers

{

? ? [ApiController]

? ? [Route("[controller]/[action]")]

? ? public class SysRoleController : ControllerBase

? ? {

? ? ? private readonly ISqlSugarClient _sqlSugarClient;

? ? ? ? private ISqlSugarClient DbBaseClient;

? ? ? ? public SysRoleController()

? ? ? ? {

? ? ? ? ? ? _sqlSugarClient = DbScoped.SugarScope;

? ? ? ? }

? ? ? ? private SqlSugarScope GetDbClient()

? ? ? ? {

? ? ? ? ? ? // 必須要as,后邊會用到切換數(shù)據(jù)庫操作

? ? ? ? ? ? return _sqlSugarClient as SqlSugarScope;

? ? ? ? }

? ? ? ? #region 獲取列表============================================================

? ? ? ? [HttpPost]

? ? ? ? [Description("獲取列表")]

? ? ? ? public async Task</*AdminUiCallBack*/ bool> GetPageList()

? ? ? ? {

? ? ? ? ? ? DbBaseClient = GetDbClient();

? ? ? ? ? var v = await DbBaseClient

? ? ? ? ? ? ? ? .Queryable<SysRole>()

? ? ? ? ? ? ? ? .ToListAsync();

? ? ? ? ? ? return true;

? ? ? ? }

? ? ? ? #endregion

? ? }

}

第1章 獲取數(shù)據(jù)庫中的數(shù)據(jù),CoreShop230628一步一步前后端開發(fā)實現(xiàn),.Net7,SqlSugarCore,WebApi

?

對以上功能更為具體實現(xiàn)和注釋見:230725_001CoreShop230628(獲取數(shù)據(jù)庫中的數(shù)據(jù))。文章來源地址http://www.zghlxwxcb.cn/news/detail-614334.html

到了這里,關(guān)于第1章 獲取數(shù)據(jù)庫中的數(shù)據(jù)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點(diǎn)擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 成為MySQL大師的第一步:輕松學(xué)習(xí)MySQL數(shù)據(jù)庫的終極指南!

    成為MySQL大師的第一步:輕松學(xué)習(xí)MySQL數(shù)據(jù)庫的終極指南!

    官網(wǎng):https://dev.mysql.com/ 1.1 安裝 1.1.1 版本 MySQL官方提供了兩個版本: 商業(yè)版本(MySQL Enterprise Edition) 該版本是收費(fèi)的,我們可以使用30天。 官方會提供對應(yīng)的技術(shù)支持。 社區(qū)版本(MySQL Community Server) 該版本是免費(fèi)的,但是MySQL不會提供任何的技術(shù)支持。 1.1.2 安裝 官網(wǎng)下載

    2024年02月06日
    瀏覽(27)
  • 在Django的數(shù)據(jù)庫操作模型中,怎樣獲取一對多或多對多關(guān)系中的所有“多”?(使用特殊屬性:逆向關(guān)系管理器)

    當(dāng)一個模型通過外鍵或多對多字段與另一個模型建立關(guān)聯(lián)時,Django會自動為該模型生成逆向關(guān)系管理器。這個逆向關(guān)系管理器的名稱是通過在模型類名后面添加 _set 來生成的。在逆向關(guān)系管理器上,你可以使用多種查詢方法來訪問相關(guān)對象。 讓我們以一個示例來說明。假設(shè)你

    2024年02月16日
    瀏覽(27)
  • Android studio引入外部SQLite數(shù)據(jù)庫,獲取數(shù)據(jù)庫列表數(shù)據(jù)

    Android studio引入外部SQLite數(shù)據(jù)庫,獲取數(shù)據(jù)庫列表數(shù)據(jù)

    準(zhǔn)備好Android studio和一個創(chuàng)建管理數(shù)據(jù)庫的軟件,推薦SQLite Expert Professional或者Navicat Premium。這里以SQLite Expert Professional為例。 1.穿件sqlite數(shù)據(jù)庫,按照自己的項目要求定義數(shù)據(jù)庫和相應(yīng)的數(shù)據(jù)表 1.在main目錄下創(chuàng)建assets文件,將準(zhǔn)備好的sqlite數(shù)據(jù)庫文件放入這個目錄下 解釋:

    2024年02月08日
    瀏覽(21)
  • Unity通過訪問java后臺獲取數(shù)據(jù)庫數(shù)據(jù)

    unity項目中,需要保存,加載大量的數(shù)據(jù)信息,對于unity直接編寫訪問數(shù)據(jù)庫的代碼畢竟麻煩。而java中的ruoyi框架可以直接根據(jù)數(shù)據(jù)庫表生成對應(yīng)的java后臺,unity調(diào)用java后臺的接口即可完成數(shù)據(jù)保存和加載。代碼如下: 代碼很簡單,但是其中涉及到的內(nèi)容需要和Java后臺開發(fā)人

    2024年02月12日
    瀏覽(23)
  • 安裝SQL Server2012到最后一步時出現(xiàn)Microsoft SQL Server 2012 Service Pack 1安裝程序出現(xiàn)以下錯誤:等待數(shù)據(jù)庫引擎恢復(fù)句柄失敗。

    安裝SQL Server2012到最后一步時出現(xiàn)Microsoft SQL Server 2012 Service Pack 1安裝程序出現(xiàn)以下錯誤:等待數(shù)據(jù)庫引擎恢復(fù)句柄失敗。

    安裝SQL Server2012到最后一步時一直出現(xiàn)Microsoft SQL Server 2012 Service Pack 1安裝程序 出現(xiàn)以下錯誤: 等待數(shù)據(jù)庫引擎恢復(fù)句柄失敗。請查看SQL Server錯誤日志以了解可能的原因。 如果忽略之后還是繼續(xù)安裝,后面結(jié)束的時候面板會顯示一些錯誤,比如: ? ? 原以為是版本和兼容的問

    2024年02月17日
    瀏覽(106)
  • JMeter從數(shù)據(jù)庫中獲取數(shù)據(jù)并作為變量使用

    目錄 前言: 1、JMeter連接MySQL數(shù)據(jù)庫 2、線程組下新建一個 JDBC Connection Configuration 配置元件 3、實現(xiàn)數(shù)據(jù)庫的查詢-單值引用 4、實現(xiàn)數(shù)據(jù)庫的查詢-多值引用 前言: 在進(jìn)行接口測試時,經(jīng)常需要使用一些動態(tài)的數(shù)據(jù),例如從數(shù)據(jù)庫中獲取用戶信息、配置參數(shù)等。JMeter提供了多個

    2024年02月12日
    瀏覽(24)
  • JMeter如何從數(shù)據(jù)庫中獲取數(shù)據(jù)并作為變量使用?

    JMeter如何從數(shù)據(jù)庫中獲取數(shù)據(jù)并作為變量使用?

    目錄 前言 1、JMeter連接MySQL數(shù)據(jù)庫 2、線程組下新建一個 JDBC Connection Configuration 配置元件 3、實現(xiàn)數(shù)據(jù)庫的查詢-單值引用 4、實現(xiàn)數(shù)據(jù)庫的查詢-多值引用 總結(jié): JMeter 如何從數(shù)據(jù)庫中獲取數(shù)據(jù)并作為變量使用?這在我們使用 JMeter 做 接口測試 、 壓力測試 時經(jīng)常碰到,今天通

    2024年02月08日
    瀏覽(37)
  • Oracle、達(dá)夢:☆獲取數(shù)據(jù)庫對象、獲取對象的DDL定義語句(達(dá)夢)

    以下方式在達(dá)夢DM數(shù)據(jù)庫中都能跑通,Oracle未測試所有的方式。 數(shù)據(jù)庫所有對象表:包括 表、視圖、物化視圖、函數(shù)、存儲過程……等 ①、ALL_OBJECTS視圖方式 OBJECT_TYPE 解釋: oracle 的ALL_OBJECTS中的OBJECT_TYPE表示: TABLE :表示表,這是用于存儲和管理數(shù)據(jù)庫中數(shù)據(jù)的主要結(jié)構(gòu)。

    2024年02月03日
    瀏覽(25)
  • 【如何獲取數(shù)據(jù)庫表的字段并拼接】

    在寫sql語句時,我要獲取到該表的大部門字段來做處理,一個個粘貼復(fù)制太費(fèi)事了,所以我決定執(zhí)行sql語句把表中字段查詢出來 其中 test 是表名, school 是數(shù)據(jù)庫名字,這樣能把該數(shù)據(jù)庫中某表的所有字段查詢出來 因為我要做查詢,需要逗號拼接,所以,對sql語句進(jìn)行了修改

    2024年02月10日
    瀏覽(18)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包