backend/Magic.Core/SqlSugar/SqlSugarSetup.cs
(开头部分) 21KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using Furion;
using Furion.Logging.Extensions;
using Magic.Core.Entity;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Linq.Expressions;
namespace Magic.Core;
public static class SqlSugarSetup
{
//public static void SqlSugarConfigure(this IServiceCollection services)
//{
// #region 配置sqlsuagr
// List<ConnectionConfig> connectConfigList = new List<ConnectionConfig>();
// //数据库序号从0开始,默认数据库为0
// var config = App.GetOptions<ConnectionStringsOptions>();
// //默认数据库
// connectConfigList.Add(new ConnectionConfig
// {
// ConnectionString = config.DefaultDbString,
// DbType = (DbType)Convert.ToInt32(Enum.Parse(typeof(DbType), config.DefaultDbType)),
// IsAutoCloseConnection = true,
// ConfigId = config.DefaultDbNumber,
// InitKeyType = InitKeyType.Attribute,
// MoreSettings = new ConnMoreSettings()
// {
// IsAutoRemoveDataCache = true//自动清理缓存
// },
// ConfigureExternalServices = new ConfigureExternalServices()
// {
// EntityNameService = (type, entity) =>
// {
// var attributes = type.GetCustomAttributes(true);
// if (attributes.Any(it => it is TableAttribute))
// {
// entity.DbTableName = (attributes.First(it => it is TableAttribute) as TableAttribute).Name;
// }
// },
// EntityService = (type, column) =>
// {
// var attributes = type.GetCustomAttributes(true);
// if (attributes.Any(it => it is KeyAttribute))// by attribute set primarykey
// {
// column.IsPrimarykey = true; //有哪些特性可以看 1.2 特性明细
// }
// if (attributes.Any(it => it is ColumnAttribute))
// {
// column.DbColumnName = (attributes.First(it => it is ColumnAttribute) as ColumnAttribute).Name;
// }
// }
// }
后面还有 400 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
