Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbSeedExtend.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Model.Models;
using Yi.Framework.Model.SeedData;

namespace Yi.Framework.WebCore.DbExtend
{
    public static class DbSeedExtend
    {
        /// <summary>
        /// 初始化数据
        /// </summary>
        /// <param name="_Db"></param>
        /// <returns></returns>
        public static bool DataInvoer(ISqlSugarClient _Db)
        {
            bool res = false;
            var users = SeedFactory.GetUserSeed();
            var roles = SeedFactory.GetRoleSeed();
            var menus = SeedFactory.GetMenuSeed();
            var dicts = SeedFactory.GetDictionarySeed();
            var posts = SeedFactory.GetPostSeed();
            var dictinfos = SeedFactory.GetDictionaryInfoSeed();
            var depts = SeedFactory.GetDeptSeed();
            var files = SeedFactory.GetFileSeed();
            try
            {
                _Db.AsTenant().BeginTran();

                if (!_Db.Queryable<UserEntity>().Any())
                {
                    _Db.Insertable(users).ExecuteCommand();
                }

                if (!_Db.Queryable<RoleEntity>().Any())
                {
                    _Db.Insertable(roles).ExecuteCommand();
                }

                if (!_Db.Queryable<MenuEntity>().Any())
                {
                    _Db.Insertable(menus).ExecuteCommand();
                }

                if (!_Db.Queryable<DictionaryEntity>().Any())
                {
                    _Db.Insertable(dicts).ExecuteCommand();
                }
                if (!_Db.Queryable<PostEntity>().Any())
                {
                    _Db.Insertable(posts).ExecuteCommand();
                }
                if (!_Db.Queryable<DictionaryInfoEntity>().Any())
                {
后面还有 74 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。