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

開發(fā)框架Furion之Winform+SqlSugar

這篇具有很好參考價(jià)值的文章主要介紹了開發(fā)框架Furion之Winform+SqlSugar。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

目錄

1.開發(fā)環(huán)境

2.項(xiàng)目搭建

2.1 創(chuàng)建WinFrom主項(xiàng)目

2.2 創(chuàng)建子項(xiàng)目

2.3 實(shí)體類庫(kù)基礎(chǔ)類信息配置

2.3.1 Nuget包及項(xiàng)目引用

2.3.2 實(shí)體基類創(chuàng)建??

2.4 倉(cāng)儲(chǔ)業(yè)務(wù)類庫(kù)基礎(chǔ)配置

2.4.1 Nuget包及項(xiàng)目引用

2.4.2 Dtos實(shí)體

2.4.3 倉(cāng)儲(chǔ)基類

?2.5 service注冊(cè)類庫(kù)基礎(chǔ)配置

2.5.1 config配置文件配置

2.5.2 Nuget包及項(xiàng)目引用

?2.5.4 SqlSugar數(shù)據(jù)庫(kù)配置

2.5.5?service服務(wù)注冊(cè)

2.6 主項(xiàng)目啟動(dòng)配置

?2.7 示例

2.7.1 codefirst 示例

?2.7.2倉(cāng)儲(chǔ)查詢調(diào)用示例

3.源代碼下載


1.開發(fā)環(huán)境

  • Visual studio 2022
  • SQLServer
  • .Net6

關(guān)于SqlSugar參見(jiàn)教程配置實(shí)體 - SqlSugar 5x - .NET果糖網(wǎng)

2.項(xiàng)目搭建

2.1 創(chuàng)建WinFrom主項(xiàng)目

Visual Studio 2022—?jiǎng)?chuàng)建新項(xiàng)目—項(xiàng)目模板中選擇 Windows窗體應(yīng)用

開發(fā)框架Furion之Winform+SqlSugar

開發(fā)框架Furion之Winform+SqlSugar

?開發(fā)框架Furion之Winform+SqlSugar

至此?項(xiàng)目初次創(chuàng)建完成?

開發(fā)框架Furion之Winform+SqlSugar

2.2 創(chuàng)建子項(xiàng)目

分別創(chuàng)建項(xiàng)目名稱為MyFurion.WFSqlsugar.Model(實(shí)體類庫(kù))、MyFurion.WFSqlsugar.Setup(service注冊(cè)類庫(kù))、MyFurion.WFSqlsugar.Application(倉(cāng)儲(chǔ)業(yè)務(wù)類庫(kù))三個(gè)子項(xiàng)目

開發(fā)框架Furion之Winform+SqlSugar

開發(fā)框架Furion之Winform+SqlSugar

開發(fā)框架Furion之Winform+SqlSugar

項(xiàng)目最終架構(gòu)

開發(fā)框架Furion之Winform+SqlSugar

2.3 實(shí)體類庫(kù)基礎(chǔ)類信息配置

2.3.1 Nuget包及項(xiàng)目引用

在MyFurion.WFSqlsugar.Model項(xiàng)目中添加SqlSugarCore

開發(fā)框架Furion之Winform+SqlSugar

2.3.2 實(shí)體基類創(chuàng)建??

創(chuàng)建基類BaseEntity.cs類

using SqlSugar;
namespace MyFurion.WFSqlsugar.Model
{
    /// <summary>
    /// 實(shí)體基類
    /// </summary>
    [SugarIndex("index_{table}_id", nameof(Id), OrderByType.Asc, IsUnique = true)]
    [SugarIndex("index_{table}_createdate", nameof(CreateTime), OrderByType.Asc)]
    [SugarIndex("index_{table}_sort", nameof(SortNum), OrderByType.Asc)]
    [SugarIndex("index_{table}_del", nameof(IsDeleted), OrderByType.Asc)]
    [SugarIndex("index_{table}_orgid", nameof(CreateOrgId), OrderByType.Asc)]
    public class BaseEntity
    {
        /// <summary>
        /// 構(gòu)造函數(shù)
        /// </summary>
        public BaseEntity()
        {
            Id = SnowFlakeSingle.Instance.NextId();
            CreateTime = DateTime.Now;
            IsDeleted = true;
        }
        /// <summary>
        /// id
        /// </summary>
        [SugarColumn(IsPrimaryKey =true, ColumnDescription ="主鍵")]
        public long Id { get; set; }   
        /// <summary>
        /// 創(chuàng)建人id
        /// </summary>
        [SugarColumn(IsOnlyIgnoreUpdate = true, IsNullable = true, ColumnDescription = "創(chuàng)建人id")]
        public string ?CreateUserId { get; set; }
        /// <summary>
        /// 創(chuàng)建人姓名
        /// </summary>
        [SugarColumn(IsOnlyIgnoreUpdate = true, IsNullable = true, ColumnDescription = "創(chuàng)建人姓名")]
        public string? CreateUser { get; set; }
        /// <summary>
        /// 創(chuàng)建時(shí)間
        /// </summary>
        [SugarColumn(IsOnlyIgnoreUpdate = true, IsNullable = false, ColumnDescription = "創(chuàng)建時(shí)間")]
        public DateTime CreateTime { get; set; }
        /// <summary>
        /// 修改人id
        /// </summary>
        [SugarColumn(IsOnlyIgnoreInsert = true, IsNullable = true, ColumnDescription = "修改人id")]
        public string? ModifyUserId { get; set; }
        /// <summary>
        /// 修改人姓名
        /// </summary>
        [SugarColumn(IsOnlyIgnoreInsert = true, IsNullable = true, ColumnDescription = "修改人姓名")]
        public string? ModifyUser { get; set; }
        /// <summary>
        /// 修改時(shí)間
        /// </summary>
        [SugarColumn(IsOnlyIgnoreInsert =true, IsNullable = true, ColumnDescription = "修改時(shí)間")]
        public DateTime? ModifyTime { get; set; }
        /// <summary>
        /// 創(chuàng)建組織機(jī)構(gòu)ID
        /// </summary>
        [SugarColumn(IsOnlyIgnoreUpdate = true, IsNullable = true, ColumnDescription = "創(chuàng)建組織機(jī)構(gòu)ID")]
        public string? CreateOrgId { get; set; }
        /// <summary>
        /// 創(chuàng)建組織機(jī)構(gòu)名稱
        /// </summary>
        [SugarColumn(IsOnlyIgnoreUpdate = true, IsNullable = true, ColumnDescription = "創(chuàng)建組織機(jī)構(gòu)名稱")]
        public string? CreateOrgName { get; set; }
        /// <summary>
        /// 排序
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnDescription = "排序")]
        public int SortNum { get; set; }
        /// <summary>
        /// 備注
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDescription = "備注",ColumnDataType ="nvarchar(max)")]
        public string? Remark { get; set; }
        /// <summary>
        /// 是否刪除
        /// </summary>
        [SugarColumn(ColumnDescription = "是否刪除")]
        public bool IsDeleted { get; set; }
        /// <summary>
        /// 刪除原因
        /// </summary>
        [SugarColumn(ColumnDescription = "刪除原因", IsNullable = true)]
        public string? DeleteReason { get; set; }
        /// <summary>
        /// 刪除時(shí)間
        /// </summary>
        [SugarColumn(IsOnlyIgnoreInsert = true, IsNullable = true, ColumnDescription = "刪除時(shí)間")]
        public DateTime? DeleteTime { get; set; }
        /// <summary>
        /// 刪除人
        /// </summary>
        [SugarColumn(ColumnDescription = "刪除人", IsNullable = true)]
        public string? DeleteUser { get; set; }
        /// <summary>
        /// 刪除單位
        /// </summary>
        [SugarColumn(ColumnDescription = "刪除單位", IsNullable = true)]
        public string? DeleteOrg { get; set; }
        /// <summary>
        /// 多租戶ID
        /// </summary>
        [SugarColumn(ColumnDescription = "多租戶ID", DefaultValue = "0")]
        public long TenantId { get; set; } = 0;
    }
}

2.4 倉(cāng)儲(chǔ)業(yè)務(wù)類庫(kù)基礎(chǔ)配置

2.4.1 Nuget包及項(xiàng)目引用

在MyFurion.WFSqlsugar.Application項(xiàng)目中添加Furion、SqlSugar.IOC

添加對(duì)MyFurion.WFSqlsugar.Model項(xiàng)目的引用

開發(fā)框架Furion之Winform+SqlSugar

開發(fā)框架Furion之Winform+SqlSugar

開發(fā)框架Furion之Winform+SqlSugar

2.4.2 Dtos實(shí)體

項(xiàng)目中創(chuàng)建Dtos文件,用于存放查詢條件以及輸出信息數(shù)據(jù)類

首先創(chuàng)建PageResult.cs和PageInputBase.cs,用于倉(cāng)儲(chǔ)基類中使用

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyFurion.WFSqlsugar.Application.Dtos
{
    /// <summary>
    /// 分頁(yè)數(shù)據(jù)
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class PageResult<T>
    {
        /// <summary>
        /// 頁(yè)碼
        /// </summary>
        public int PageNo { get; set; }
        /// <summary>
        /// 分頁(yè)大小
        /// </summary>
        public int PageSize { get; set; }
        /// <summary>
        /// 頁(yè)總數(shù)
        /// </summary>
        public int TotalPage { get; set; }
        /// <summary>
        /// 數(shù)據(jù)總數(shù)
        /// </summary>
        public int TotalRows { get; set; }
        /// <summary>
        /// 記錄集合
        /// </summary>
        public List<T> Rows { get; set; } = new();
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyFurion.WFSqlsugar.Application.Dtos
{
    public class PageInputBase
    {
        /// <summary>
        /// 搜索值
        /// </summary>
        public  string? SearchValue { get; set; }
        /// <summary>
        /// 當(dāng)前頁(yè)碼
        /// </summary>
        public  int PageNo { get; set; } = 1;
        /// <summary>
        /// 頁(yè)碼容量
        /// </summary>
        public  int PageSize { get; set; } = 20;
        /// <summary>
        /// 搜索開始時(shí)間
        /// </summary>
        public string? SearchBeginTime { get; set; }
        /// <summary>
        /// 搜索結(jié)束時(shí)間
        /// </summary>
        public  string?SearchEndTime { get; set; }
    }
}

2.4.3 倉(cāng)儲(chǔ)基類

創(chuàng)建倉(cāng)儲(chǔ)基類BaseRepository.cs

using System.Reflection;
using System.Linq.Expressions;
using System.Data;
using MyFurion.WFSqlsugar.Model;
using MyFurion.WFSqlsugar.Application.Dtos;
using SqlSugar;
using SqlSugar.IOC;
using Furion.Logging;
namespace MyFurion.WFSqlsugar.Application
{
    public class BaseRepository<T> : SimpleClient<T> where T : BaseEntity, new()
    {
        public ITenant itenant = null;//多租戶事務(wù)
        //private readonly ISqlSugarRepository repository;
        public BaseRepository(ISqlSugarClient context = null) : base(context)
        {
            //通過(guò)特性拿到ConfigId
            var configId = typeof(T).GetCustomAttribute<TenantAttribute>()?.configId;
            if (configId != null)
            {
                Context = DbScoped.SugarScope.GetConnectionScope(configId);//根據(jù)類傳入的ConfigId自動(dòng)選擇
            }
            else
            {
                Context = context ?? DbScoped.SugarScope.GetConnectionScope(0);//沒(méi)有默認(rèn)db0
            }
            //Context = DbScoped.SugarScope.GetConnectionScopeWithAttr<T>();
            itenant = DbScoped.SugarScope;//設(shè)置租戶接口
        }

        #region 基礎(chǔ)業(yè)務(wù)
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public async Task<bool> Add(T t)
        {
            try
            {
                int rowsAffect = await Context.Insertable(t).IgnoreColumns(true).ExecuteCommandAsync();
                return rowsAffect > 0;
            }
            catch (Exception ex)
            {
                Log.Error($"新增失?。簕ex.Message}");
                return false;
            }
        }
        /// <summary>
        /// 批量新增
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public async Task<bool> Insert(List<T> t)
        {
            try
            {
                int rowsAffect = await Context.Insertable(t).ExecuteCommandAsync();
                return rowsAffect > 0;
            }
            catch (Exception ex)
            {
                Log.Error($"批量新增失?。簕ex.Message}");
                return false;
            }
        }
        /// <summary>
        /// 插入設(shè)置列數(shù)據(jù)
        /// </summary>
        /// <param name="parm"></param>
        /// <param name="iClumns"></param>
        /// <param name="ignoreNull"></param>
        /// <returns></returns>
        public async Task<bool> Insert(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true)
        {
            try
            {
                int rowsAffect = await Context.Insertable(parm).InsertColumns(iClumns).IgnoreColumns(ignoreNullColumn: ignoreNull).ExecuteCommandAsync();
                return rowsAffect > 0;
            }
            catch (Exception ex)
            {
                Log.Error($"插入設(shè)置列數(shù)據(jù)失?。簕ex.Message}");
                return false;
            }
        }
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="ignoreNullColumns"></param>
        /// <returns></returns>
        public async Task<bool> Update(T entity, bool ignoreNullColumns = false)
        {
            try
            {
                int rowsAffect = await Context.Updateable(entity).IgnoreColumns(ignoreNullColumns).ExecuteCommandAsync();
                return rowsAffect >= 0;
            }
            catch (Exception ex)
            {
                Log.Error($"更新失?。簕ex.Message}");
                return false;
            }
        }
        /// <summary>
        /// 根據(jù)實(shí)體類更新指定列 eg:Update(dept, it => new { it.Status });只更新Status列,條件是包含
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="expression"></param>
        /// <param name="ignoreAllNull"></param>
        /// <returns></returns>
        public async Task<bool> Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false)
        {
            try
            {
                int rowsAffect = await Context.Updateable(entity).UpdateColumns(expression).IgnoreColumns(ignoreAllNull).ExecuteCommandAsync();
                return rowsAffect >= 0;
            }
            catch (Exception ex)
            {
                Log.Error($"根據(jù)實(shí)體類更新指定列失敗:{ex.Message}");
                return false;
            }
        }
        /// <summary>
        /// 根據(jù)實(shí)體類更新指定列 eg:Update(dept, it => new { it.Status }, f => depts.Contains(f.DeptId));只更新Status列,條件是包含
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="expression"></param>
        /// <param name="where"></param>
        /// <returns></returns>
        public async Task<bool> Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where)
        {
            try
            {
                int rowsAffect = await Context.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommandAsync();
                return rowsAffect >= 0;
            }
            catch (Exception ex)
            {
                Log.Error($"根據(jù)實(shí)體類更新指定列失敗:{ex.Message}");
                return false;
            }
        }
        /// <summary>
        /// 更新指定列 eg:Update(w => w.NoticeId == model.NoticeId, it => new SysNotice(){ UpdateTime = DateTime.Now, Title = "通知標(biāo)題" });
        /// </summary>
        /// <param name="where"></param>
        /// <param name="columns"></param>
        /// <returns></returns>
        public async Task<bool> Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns)
        {
            try
            {
                int rowsAffect = await Context.Updateable<T>().SetColumns(columns).Where(where).RemoveDataCache().ExecuteCommandAsync();
                return rowsAffect >= 0;
            }
            catch (Exception ex)
            {
                Log.Error($"更新指定列失?。簕ex.Message}");
                return false;
            }
        }
        /// <summary>
        /// 事務(wù) eg:var result = UseTran(() =>{SysRoleRepository.UpdateSysRole(sysRole);DeptService.DeleteRoleDeptByRoleId(sysRole.ID);DeptService.InsertRoleDepts(sysRole);});
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        public bool UseTran(Action action)
        {
            try
            {
                var result = Context.Ado.UseTran(() => action());
                return result.IsSuccess;
            }
            catch (Exception ex)
            {
                Context.Ado.RollbackTran();
                Log.Error($"事務(wù)執(zhí)行失?。簕ex.Message}");
                return false;
            }
        }
        /// <summary>
        /// 刪除
        /// </summary>
        /// <param name="id">主鍵id</param>
        /// <param name="IsDelete">是否真刪除</param>
        /// <returns></returns>
        public async Task<bool> DeleteById(long id, bool IsDelete = false)
        {
            int rowsAffect = 0;
            try
            {
                if (IsDelete)
                {
                    rowsAffect = await Context.Deleteable<T>().In(id).ExecuteCommandAsync();
                }
                else
                {
                    //假刪除 實(shí)體屬性有isdelete或者isdeleted 請(qǐng)升級(jí)到5.0.4.9+,(5.0.4.3存在BUG)
                    rowsAffect = await Context.Deleteable<T>().In(id).IsLogic().ExecuteCommandAsync();
                }
                return rowsAffect > 0;
            }
            catch (Exception ex)
            {
                Log.Error($"刪除失?。簕ex.Message}");
                return false;
            }
        }
        /// <summary>
        /// 根據(jù)查詢條件刪除
        /// </summary>
        /// <param name="where"></param>
        /// <param name="IsDelete"></param>
        /// <returns></returns>
        public async Task<bool> DeleteByWhere(Expression<Func<T, bool>> where, bool IsDelete = false)
        {
            int rowsAffect = 0;
            try
            {
                if (IsDelete)
                {
                    rowsAffect = await Context.Deleteable<T>().Where(where).ExecuteCommandAsync();
                }
                else
                {
                    //假刪除 實(shí)體屬性有isdelete或者isdeleted 請(qǐng)升級(jí)到5.0.4.9+,(5.0.4.3存在BUG)
                    rowsAffect = await Context.Deleteable<T>().Where(where).IsLogic().ExecuteCommandAsync();
                }
                return rowsAffect > 0;
            }
            catch (Exception ex)
            {
                Log.Error($"根據(jù)查詢條件刪除失?。簕ex.Message}");
                return false;
            }
        }
        /// <summary>
        /// 根據(jù)id獲取數(shù)據(jù)
        /// </summary>
        /// <param name="id">主鍵值</param>
        /// <returns>泛型實(shí)體</returns>
        public async Task<T> GetEntityById(long id)
        {
            return await Context.Queryable<T>().FirstAsync(p => p.Id == id);
        }
        /// <summary>
        /// 數(shù)據(jù)是否存在
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        public async Task<bool> IsExists(Expression<Func<T, bool>> expression)
        {
            return await Context.Queryable<T>().Where(expression).AnyAsync();
        }
        /// <summary>
        /// 獲取所有數(shù)據(jù)
        /// </summary>
        /// <returns></returns>
        public async Task<List<T>> GetAll()
        {
            return await Context.Queryable<T>().ToListAsync();
        }
        /// <summary>
        /// 根據(jù)查詢條件獲取數(shù)據(jù)
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        public async Task<List<T>> GetListByWhere(Expression<Func<T, bool>> expression)
        {
            return await Context.Queryable<T>().Where(expression).ToListAsync();
        }
        /// <summary>
        /// 根據(jù)查詢條件獲取數(shù)據(jù)(動(dòng)態(tài)表格拼接查詢條件)
        /// </summary>
        /// <param name="conditions"></param>
        /// <returns></returns>
        public async Task<List<T>> GetListByWhere(List<IConditionalModel> conditions)
        {
            return await Context.Queryable<T>().Where(conditions).ToListAsync();
        }
        /// <summary>
        /// 根據(jù)查詢條件獲取數(shù)據(jù)
        /// </summary>
        /// <param name="expression"></param>
        /// <param name="orderFiled">排序字段</param>
        /// <param name="orderEnum">排序方式</param>
        /// <returns></returns>
        public async Task<List<T>> GetList(Expression<Func<T, bool>> expression, Expression<Func<T, object>> orderFiled, OrderByType orderEnum = OrderByType.Desc)
        {
            return await Context.Queryable<T>().Where(expression).OrderByIF(orderEnum == OrderByType.Asc, orderFiled, OrderByType.Asc).OrderByIF(orderEnum == OrderByType.Desc, orderFiled, OrderByType.Desc).ToListAsync();
        }
        /// <summary>
        /// 獲取分頁(yè)數(shù)據(jù)
        /// </summary>
        /// <param name="expression"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public PageResult<T> GetPageList(Expression<Func<T, bool>> expression, int pageIndex, int pageSize)
        {
            int totalCount = 0;
            var result = Context.Queryable<T>().Where(expression).ToPageList(pageIndex, pageSize, ref totalCount);
            var pageResult = new PageResult<T>();
            pageResult.Rows = result;
            pageResult.TotalRows = totalCount;
            pageResult.TotalPage = (int)Math.Ceiling(totalCount / (double)pageSize);
            return pageResult;
        }
        /// <summary>
        /// 獲取分頁(yè)數(shù)據(jù)
        /// </summary>
        /// <param name="expression"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public async Task<PageResult<T>> GetPageListAsync(Expression<Func<T, bool>> expression, int pageIndex, int pageSize)
        {
            RefAsync<int> totalCount = 0;
            var result = await Context.Queryable<T>().Where(expression).ToPageListAsync(pageIndex, pageSize, totalCount);
            var pageResult = new PageResult<T>();
            pageResult.Rows = result;
            pageResult.TotalRows = totalCount;
            pageResult.TotalPage = (int)Math.Ceiling(totalCount / (double)pageSize);
            return pageResult;
        }
        /// <summary>
        /// 獲取分頁(yè)數(shù)據(jù)
        /// </summary>
        /// <param name="expression"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="orderFiled"></param>
        /// <param name="orderEnum"></param>
        /// <returns></returns>
        public PageResult<T> GetPageList(Expression<Func<T, bool>> expression, int pageIndex, int pageSize, Expression<Func<T, object>> orderFiled, OrderByType orderEnum = OrderByType.Desc)
        {
            int totalCount = 0;
            var result = Context.Queryable<T>().Where(expression).OrderByIF(orderEnum == OrderByType.Asc, orderFiled, OrderByType.Asc).OrderByIF(orderEnum == OrderByType.Desc, orderFiled, OrderByType.Desc)
                .ToPageList(pageIndex, pageSize, ref totalCount);
            var pageResult = new PageResult<T>();
            pageResult.Rows = result;
            pageResult.TotalRows = totalCount;
            pageResult.TotalPage = (int)Math.Ceiling(totalCount / (double)pageSize);
            return pageResult;
        }
        /// <summary>
        /// 獲取分頁(yè)數(shù)據(jù)
        /// </summary>
        /// <param name="expression"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="orderFiled"></param>
        /// <param name="orderEnum"></param>
        /// <returns></returns>
        public async Task<PageResult<T>> GetPageListAsync(Expression<Func<T, bool>> expression, int pageIndex, int pageSize, Expression<Func<T, object>> orderFiled, OrderByType orderEnum = OrderByType.Desc)
        {
            RefAsync<int> totalCount = 0;
            var result = await Context.Queryable<T>().Where(expression).OrderByIF(orderEnum == OrderByType.Asc, orderFiled, OrderByType.Asc).OrderByIF(orderEnum == OrderByType.Desc, orderFiled, OrderByType.Desc)
                .ToPageListAsync(pageIndex, pageSize, totalCount);
            var pageResult = new PageResult<T>();
            pageResult.Rows = result;
            pageResult.TotalRows = totalCount;
            pageResult.TotalPage = (int)Math.Ceiling(totalCount / (double)pageSize);
            return pageResult;
        }
        /// <summary>
        /// 獲取分頁(yè)數(shù)據(jù)
        /// </summary>
        /// <param name="expression"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="orderFiled"></param>
        /// <param name="orderEnum"></param>
        /// <returns></returns>
        public async Task<PageResult<T>> GetOffsetPageListAsync(Expression<Func<T, bool>> expression, int pageIndex, int pageSize, Expression<Func<T, object>> orderFiled, OrderByType orderEnum = OrderByType.Desc)
        {
            RefAsync<int> totalCount = 0;
            var result = await Context.Queryable<T>().Where(expression).OrderByIF(orderEnum == OrderByType.Asc, orderFiled, OrderByType.Asc).OrderByIF(orderEnum == OrderByType.Desc, orderFiled, OrderByType.Desc)
                .ToOffsetPageAsync(pageIndex, pageSize, totalCount);
            var pageResult = new PageResult<T>();
            pageResult.Rows = result;
            pageResult.TotalRows = totalCount;
            pageResult.TotalPage = (int)Math.Ceiling(totalCount / (double)pageSize);
            return pageResult;
        }
        #endregion

        #region 海量業(yè)務(wù)高性能
        /// <summary>
        /// 新增(對(duì)于海量數(shù)據(jù)并且性能要高的)
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public async Task<bool> BulkAdd(T t)
        {
            try
            {
                int rowsAffect = await Context.Storageable(t).ToStorage().BulkCopyAsync();
                return rowsAffect > 0;
            }
            catch (Exception ex)
            {
                Log.Error($"新增失敗:{ex.Message}");
                return false;
            }
        }
        /// <summary>
        /// 批量新增(對(duì)于海量數(shù)據(jù)并且性能要高的)
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public async Task<bool> BatchBulkAdd(List<T> t)
        {
            try
            {
                int rowsAffect = await Context.Storageable(t).ToStorage().BulkCopyAsync();
                return rowsAffect > 0;
            }
            catch (Exception ex)
            {
                Log.Error($"批量新增失?。簕ex.Message}");
                return false;
            }
        }
        /// <summary>
        /// 更新(對(duì)于海量數(shù)據(jù)并且性能要高的)
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public async Task<bool> BulkUpdate(T entity)
        {
            try
            {
                int rowsAffect = await Context.Storageable(entity).ToStorage().BulkUpdateAsync();
                return rowsAffect >= 0;
            }
            catch (Exception ex)
            {
                Log.Error($"更新失敗:{ex.Message}");
                return false;
            }
        }
        /// <summary>
        /// 批量更新(對(duì)于海量數(shù)據(jù)并且性能要高的)
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public async Task<bool> BatchBulkUpdate(List<T> t)
        {
            try
            {
                Context.QueryFilter = new QueryFilterProvider();//清空過(guò)濾器 否則會(huì)出現(xiàn)Parameter '@IsDelete0' must be defined錯(cuò)誤
                int rowsAffect = await Context.Storageable(t).ToStorage().BulkUpdateAsync();
                return rowsAffect >= 0;
            }
            catch (Exception ex)
            {
                Log.Error($"更新失?。簕ex.Message}");
                return false;
            }
        }
        /// <summary>
        /// 批量更新(對(duì)于海量數(shù)據(jù)并且性能要高的)
        /// </summary>
        /// <param name="t"></param>
        /// <param name="updateColumns"></param>
        /// <returns></returns>
        public async Task<bool> BatchBulkUpdate(List<T> t, string[] updateColumns)
        {
            try
            {
                Context.QueryFilter = new QueryFilterProvider();//清空過(guò)濾器 否則會(huì)出現(xiàn)Parameter '@IsDelete0' must be defined錯(cuò)誤
                int rowsAffect = await Context.Storageable(t).ToStorage().BulkUpdateAsync(updateColumns);
                return rowsAffect >= 0;
            }
            catch (Exception ex)
            {
                Log.Error($"更新失?。簕ex.Message}");
                return false;
            }
        }
        #endregion

        #region 存儲(chǔ)過(guò)程
        /// <summary>
        /// 存儲(chǔ)過(guò)程
        /// </summary>
        /// <param name="procedureName"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public async Task<DataTable> ProcedureQuery(string procedureName, object parameters)
        {
            return await Context.Ado.UseStoredProcedure().GetDataTableAsync(procedureName, parameters);
        }
        /// <summary>
        /// 存儲(chǔ)過(guò)程
        /// </summary>
        /// <param name="procedureName"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public async Task<List<T>> ProcedureQueryList(string procedureName, object parameters)
        {
            return await Context.Ado.UseStoredProcedure().SqlQueryAsync<T>(procedureName, parameters);
        }
        #endregion

        #region Fastest
        /// <summary>
        /// 批量新增
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public async Task<bool> BatchFastestkAdd(List<T> t)
        {
            try
            {
                int rowsAffect = await Context.Fastest<T>().BulkCopyAsync(t);
                return rowsAffect > 0;
            }
            catch (Exception ex)
            {
                Log.Error($"fastest批量新增失?。簕ex.Message}");
                return false;
            }
        }
        /// <summary>
        /// 批量更新
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public async Task<bool> BatchFastestUpdate(List<T> t)
        {
            try
            {
                Context.QueryFilter = new QueryFilterProvider();//清空過(guò)濾器 否則會(huì)出現(xiàn)Parameter '@IsDelete0' must be defined錯(cuò)誤
                int rowsAffect = await Context.Fastest<T>().BulkUpdateAsync(t);
                return rowsAffect >= 0;
            }
            catch (Exception ex)
            {
                Log.Error($"fastest批量更新失敗:{ex.Message}");
                return false;
            }
        }
        #endregion
    }
}

?2.5 service注冊(cè)類庫(kù)基礎(chǔ)配置

2.5.1 config配置文件配置

?首先在主項(xiàng)目MyFurion.WFSqlSugar中新增App.config配置文件,并配置數(shù)據(jù)庫(kù)連接配置

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
	<appSettings>
		<!--數(shù)據(jù)庫(kù)連接-->
		<add key="SqlserverConn" value="Data Source=.;User ID=sa;Password=123456;Initial Catalog=MyFurionTest"/>
		<!--是否需要codeFirst模式-->
		<add key="IsCodeFirst" value="1"/>
	</appSettings>
</configuration>

2.5.2 Nuget包及項(xiàng)目引用

在項(xiàng)目MyFurion.WFSqlsugar.Setup中添加對(duì)項(xiàng)目MyFurion.WFSqlsugar.Application的引用

添加Furion.Extras.DatabaseAccessor.SqlSugar、System.Configuration.ConfigurationManager、System.Linq.Dynamic.Core

開發(fā)框架Furion之Winform+SqlSugar

開發(fā)框架Furion之Winform+SqlSugar

?2.5.4 SqlSugar數(shù)據(jù)庫(kù)配置

?創(chuàng)建SqlSugarSet.cs文件,用于對(duì)SqlSugar數(shù)據(jù)庫(kù)連接的配置數(shù)據(jù)

using System.Linq.Expressions;
using System.Linq.Dynamic.Core;
using System.Reflection;
using MyFurion.WFSqlsugar.Model;
using SqlSugar;
using SqlSugar.IOC;
using Furion.Logging;
namespace MyFurion.WFSqlsugar.Setup
{
    /// <summary>
    /// 數(shù)據(jù)庫(kù)配置
    /// </summary>
    public class SqlSugarSet
    {
        public static void AddSqlsugarSetup()
        {
            string sqlserverConn = System.Configuration.ConfigurationManager.AppSettings["SqlserverConn"].ToString();
            string isCodefirst= System.Configuration.ConfigurationManager.AppSettings["IsCodeFirst"].ToString();
            //string orcaleConn = System.Configuration.ConfigurationManager.AppSettings["OrcaleConn"].ToString();
            List<IocConfig> iocConfigs = new List<IocConfig>()
            {
                new IocConfig (){ ConnectionString=sqlserverConn,ConfigId=0,IsAutoCloseConnection=true,DbType=IocDbType.SqlServer},
                //new IocConfig (){ ConnectionString=orcaleConn,ConfigId=1,IsAutoCloseConnection=true,DbType=IocDbType.Oracle}
            };
            SugarIocServices.AddSqlSugar(iocConfigs);
            SugarIocServices.ConfigurationSugar(db =>
            {
                foreach (var iocItem in iocConfigs)
                {
                    SqlSugarProvider dbClient = db.GetConnection(iocItem.ConfigId);
                    SetQueryFilter(dbClient);
                    //sql執(zhí)行語(yǔ)句日志
                    dbClient.Aop.OnLogExecuting = (sql, pars) =>
                    {
                        try
                        {
                            Log.Information(SqlProfiler.ParameterFormat(sql, pars));
                        }
                        catch (Exception ex)
                        {
                            Log.Error($"日志錯(cuò)誤{ex.StackTrace}");
                        }
                    };
                }
            });
            if (isCodefirst == "1")
            {
                CreateTable(iocConfigs);
            }
        }
        /// <summary>
        /// 創(chuàng)建數(shù)據(jù)庫(kù)表 codefirst
        /// </summary>
        private static void CreateTable(List<IocConfig> iocConfigs)
        {
            foreach (var item in iocConfigs)
            {
                string configId = item.ConfigId;
                ISqlSugarClient db = DbScoped.SugarScope.GetConnectionScope(configId);
                db.DbMaintenance.CreateDatabase();//沒(méi)有數(shù)據(jù)庫(kù)的時(shí)候創(chuàng)建數(shù)據(jù)庫(kù)
                var tableLists = db.DbMaintenance.GetTableInfoList();
                var files = System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "MyFurion.WFSqlsugar.Model.dll");
                if (files.Length > 0)
                {
                    Type[] types = Assembly.LoadFrom(files[0]).GetTypes().Where(it => it.BaseType == typeof(BaseEntity)).ToArray();
                    //Type[] types = Assembly.LoadFrom(files[0]).GetTypes().ToArray();
                    foreach (var entityType in types)
                    {
                        //創(chuàng)建數(shù)據(jù)表
                        string tableName = entityType.GetCustomAttribute<SugarTable>().TableName.ToLower();//根據(jù)特性獲取表名稱
                        var configid = entityType.GetCustomAttribute<TenantAttribute>()?.configId;//根據(jù)特性獲取租戶id
                        configid = configid == null ? "0" : configid.ToString();
                        if (!tableLists.Any(p => p.Name == tableName) && configId == configid.ToString())
                        {
                            //創(chuàng)建數(shù)據(jù)表包括字段更新
                            db.CodeFirst.InitTables(entityType);
                        }
                    }
                    db.Close();
                }
            }
        }
        /// <summary>
        /// 添加全局過(guò)濾器
        /// </summary>
        /// <param name="provider"></param>
        private static void SetQueryFilter(SqlSugarProvider provider)
        {
            //添加全局過(guò)濾器
            var files = System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "MyFurion.WFSqlsugar.Model.dll");
            if (files.Length > 0)
            {
                Type[] types = Assembly.LoadFrom(files[0]).GetTypes().Where(it => it.BaseType == typeof(BaseEntity)).ToArray();
                foreach (var entityType in types)
                {
                    //string tableName = entityType.GetCustomAttribute<SugarTable>().TableName;//根據(jù)特性獲取表名稱
                    var lambda =DynamicExpressionParser.ParseLambda(new[] { Expression.Parameter(entityType, "it") },
                        typeof(bool), $"{nameof(BaseEntity.IsDeleted)} ==  @0",false);
                    provider.QueryFilter.Add(new TableFilterItem<object>(entityType, lambda, true)); //將Lambda傳入過(guò)濾器
                }
            }
            //插入/更新過(guò)濾器,用于審計(jì)日志
            provider.Aop.DataExecuting = (oldValue, entityInfo) =>
            {
                //新增時(shí)操作
                if (entityInfo.OperationType == DataFilterType.InsertByObject)
                {

                }
                //修改時(shí)操作        
                if (entityInfo.OperationType == DataFilterType.UpdateByObject)
                {
                    if (entityInfo.PropertyName == "ModifyTime")
                    {
                        entityInfo.SetValue(DateTimeOffset.Now);//修改UpdateTime字段
                    }
                }
            };
        }
    }
}

2.5.5?service服務(wù)注冊(cè)

創(chuàng)建YourStartup.cs,用于Furion框架的相關(guān)service的服務(wù)注冊(cè)

using Furion;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

namespace MyFurion.WFSqlsugar.Setup
{
    public class YourStartup : AppStartup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            //services.AddRemoteRequest();
            services.AddDatabaseAccessor();//使用數(shù)據(jù)庫(kù)配置
            services.AddLogging();//日志服務(wù)
            //設(shè)置日志
            System.Array.ForEach(new[] { LogLevel.Information, LogLevel.Error }, logLevel =>
            {
                services.AddFileLogging("Logs/{1}-{0:yyyy}-{0:MM}-{0:dd}-{0:HH}.log", options =>
                {
                    options.FileNameRule = fileName => string.Format(fileName, System.DateTime.UtcNow, logLevel.ToString());
                    options.WriteFilter = logMsg => logMsg.LogLevel == logLevel;
                    options.Append = true;
                    //options.MessageFormat = (logMsg) =>
                    //{
                    //    var stringBuilder = new System.Text.StringBuilder();
                    //    stringBuilder.Append(System.DateTime.Now.ToString("o"));
                    //    // 其他的。。。自己組裝
                    //    return stringBuilder.ToString();
                    //};
                });
            });
            SqlSugarSet.AddSqlsugarSetup();
        }
    }
}

2.6 主項(xiàng)目啟動(dòng)配置

在項(xiàng)目MyFurion.WFSqlSugar添加對(duì)項(xiàng)目MyFurion.WFSqlsugar.Setup的引用

Program.cs中添加代碼

 Serve.RunNative(includeWeb: false);//furion框架配置,默認(rèn)啟動(dòng)

開發(fā)框架Furion之Winform+SqlSugar

?2.7 示例

2.7.1 codefirst 示例

創(chuàng)建SystemUser.cs實(shí)體類,配置相關(guān)表名及租戶id

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;

namespace MyFurion.WFSqlsugar.Model
{
    [SugarTable("Sys_User")]
    [Tenant("0")]
    public class SystemUser:BaseEntity
    {
        /// <summary>
        /// 賬號(hào)
        /// </summary>
        [SugarColumn(Length = 50, ColumnDescription = "賬號(hào)")]
        public string Account { get; set; }
        /// <summary>
        /// 密碼(默認(rèn)MD5加密)
        /// </summary>
        [SugarColumn(Length = 50, ColumnDescription = "密碼")]
        public string Password { get; set; }
        /// <summary>
        /// 昵稱
        /// </summary>
        [SugarColumn(Length = 20, IsNullable = true, ColumnDescription = "昵稱")]
        public string NickName { get; set; }
        /// <summary>
        /// 姓名
        /// </summary>
        [SugarColumn(Length = 20, IsNullable = true, ColumnDescription = "姓名")]
        public string UserName { get; set; }
    }
}

啟動(dòng)項(xiàng)目,自動(dòng)創(chuàng)建數(shù)據(jù)表,效果展示

開發(fā)框架Furion之Winform+SqlSugar

?2.7.2倉(cāng)儲(chǔ)查詢調(diào)用示例

用戶倉(cāng)儲(chǔ)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Furion.DependencyInjection;
using MyFurion.WFSqlsugar.Model;
using MyFurion.WFSqlsugar.Application.Dtos;
using SqlSugar;
using System.Linq.Expressions;

namespace MyFurion.WFSqlsugar.Application
{
    /// <summary>
    /// 用戶倉(cāng)儲(chǔ)業(yè)務(wù)
    /// </summary>
    public class UserRepository : BaseRepository<SystemUser>, ITransient
    {
        /// <summary>
        /// 賬戶是否已存在
        /// </summary>
        /// <param name="account"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<bool> IsExists(string account, long id)
        {
            return await Context.Queryable<SystemUser>().AnyAsync(x => x.Account == account && x.Id != id);
        }
        /// <summary>
        /// 分頁(yè)數(shù)據(jù)
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<PageResult<SystemUser>> GetPageList(PageInputBase input)
        {
            var exp = Expressionable.Create<SystemUser>();
            exp.AndIF(!string.IsNullOrWhiteSpace(input.SearchValue), it => it.UserName.Contains(input.SearchValue)||it.Account.Contains(input.SearchValue));
            Expression<Func<SystemUser, dynamic>> sortPredicate = x => x.CreateTime;
            return await GetPageListAsync(exp.ToExpression(),input.PageNo,input.PageSize, sortPredicate);
        }
    }
}

form頁(yè)面調(diào)用查詢

開發(fā)框架Furion之Winform+SqlSugar

using Furion;
using MyFurion.WFSqlsugar.Application;
using MyFurion.WFSqlsugar.Application.Dtos;
using MyFurion.WFSqlsugar.Model;

namespace MyFurion.WFSqlSugar
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
           UserRepository userRepository= App.GetService<UserRepository>();
           var data = userRepository.GetPageList(new PageInputBase() { PageNo=1,PageSize=20}).Result;
        }
    }
}

3.源代碼下載

WinformFurion: winform +Furion+SqlSugar框架,codefirst模式、包含日志、積累倉(cāng)儲(chǔ)的增刪改查等文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-425568.html

到了這里,關(guān)于開發(fā)框架Furion之Winform+SqlSugar的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

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

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

相關(guān)文章

  • 基于SqlSugar的開發(fā)框架循序漸進(jìn)介紹(30)-- 整合客戶關(guān)系管理系統(tǒng)模塊功能

    基于SqlSugar的開發(fā)框架循序漸進(jìn)介紹(30)-- 整合客戶關(guān)系管理系統(tǒng)模塊功能

    以前在隨筆《Winform開發(fā)框架之客戶關(guān)系管理系統(tǒng)(CRM)的開發(fā)總結(jié)系列1-界面功能展示?》的幾篇隨筆中介紹過(guò)基于WInform開發(fā)框架開發(fā)的CRM系統(tǒng),系統(tǒng)的功能主要也是圍繞著客戶相關(guān)信息來(lái)進(jìn)行管理的,經(jīng)過(guò)一些客戶的定制應(yīng)用,以及框架各種功能的完善,系統(tǒng)也已經(jīng)很完善了

    2024年02月07日
    瀏覽(20)
  • 基于SqlSugar的開發(fā)框架循序漸進(jìn)介紹(27)-- 基于MongoDB的數(shù)據(jù)庫(kù)操作整合

    基于SqlSugar的開發(fā)框架循序漸進(jìn)介紹(27)-- 基于MongoDB的數(shù)據(jù)庫(kù)操作整合

    SqlSugar的開發(fā)框架本身主要是基于常規(guī)關(guān)系型數(shù)據(jù)庫(kù)設(shè)計(jì)的框架,支持多種數(shù)據(jù)庫(kù)類型的接入,如SqlServer、MySQL、Oracle、PostgreSQL、SQLite等數(shù)據(jù)庫(kù),非關(guān)系型數(shù)據(jù)庫(kù)的MongoDB數(shù)據(jù)庫(kù)也可以作為擴(kuò)展整合到開發(fā)框架里面,通過(guò)基類的繼承關(guān)系很好的封裝了相關(guān)的基礎(chǔ)操作功能,極大

    2023年04月13日
    瀏覽(27)
  • 基于SqlSugar的開發(fā)框架循序漸進(jìn)介紹(29)-- 快速構(gòu)建系統(tǒng)參數(shù)管理界面-Vue3+ElementPlus

    基于SqlSugar的開發(fā)框架循序漸進(jìn)介紹(29)-- 快速構(gòu)建系統(tǒng)參數(shù)管理界面-Vue3+ElementPlus

    在隨筆《基于SqlSugar的開發(fā)框架循序漸進(jìn)介紹(28)-- 快速構(gòu)建系統(tǒng)參數(shù)管理界面》中介紹了基于SqlSugar開發(fā)框架,構(gòu)建系統(tǒng)參數(shù)管理的后端API部分,以及WInform界面部分內(nèi)容,本篇隨筆介紹基于Vue3+ElementPlus的前端界面開發(fā)過(guò)程。 系統(tǒng)參數(shù)的信息,設(shè)計(jì)為包含一個(gè)大類參數(shù)目錄

    2024年02月02日
    瀏覽(24)
  • 基于SqlSugar的開發(fā)框架循序漸進(jìn)介紹(26)-- 實(shí)現(xiàn)本地上傳、FTP上傳、阿里云OSS上傳三者合一處理

    基于SqlSugar的開發(fā)框架循序漸進(jìn)介紹(26)-- 實(shí)現(xiàn)本地上傳、FTP上傳、阿里云OSS上傳三者合一處理

    在前面介紹的隨筆《基于SqlSugar的開發(fā)框架循序漸進(jìn)介紹(7)-- 在文件上傳模塊中采用選項(xiàng)模式【Options】處理常規(guī)上傳和FTP文件上傳》中介紹過(guò)在文件上傳處理的過(guò)程中,整合了本地文件上傳和基于FTP方式的上傳文件的處理整合。本篇隨筆繼續(xù)介紹文件上傳的處理,基于選項(xiàng)

    2023年04月10日
    瀏覽(34)
  • 基于SqlSugar的開發(fā)框架循序漸進(jìn)介紹(31)-- 在查詢接口中實(shí)現(xiàn)多表聯(lián)合和單表對(duì)象的統(tǒng)一處理

    基于SqlSugar的開發(fā)框架循序漸進(jìn)介紹(31)-- 在查詢接口中實(shí)現(xiàn)多表聯(lián)合和單表對(duì)象的統(tǒng)一處理

    在一些復(fù)雜的業(yè)務(wù)表中間查詢數(shù)據(jù),有時(shí)候操作會(huì)比較復(fù)雜一些,不過(guò)基于SqlSugar的相關(guān)操作,處理的代碼會(huì)比較簡(jiǎn)單一些,以前我在隨筆《基于SqlSugar的開發(fā)框架循序漸進(jìn)介紹(2)-- 基于中間表的查詢處理》介紹過(guò)基于主表和中間表的聯(lián)合查詢,而往往實(shí)際會(huì)比這個(gè)會(huì)復(fù)雜

    2024年02月07日
    瀏覽(24)
  • SqlSugar框架之WPF應(yīng)用端功能介紹

    SqlSugar框架之WPF應(yīng)用端功能介紹

    ?WPF應(yīng)用端是我們《SqlSugar開發(fā)框架》多端界面中的一部分,和Winform前端框架、Vue3+ElementPlus前端、UniApp+Thorn移動(dòng)端,組成一個(gè)完整的整體框架,后端服務(wù)是基于SqlSugar的基礎(chǔ)ORM的.netcore框架,提供Web API服務(wù)供各個(gè)前端使用,底層支持多種數(shù)據(jù)庫(kù),包括SqlServer、Oracle、Mysql、Po

    2024年02月08日
    瀏覽(17)
  • C# WinForm —— 項(xiàng)目目錄結(jié)構(gòu)

    C# WinForm —— 項(xiàng)目目錄結(jié)構(gòu)

    C# WinForm —— Program類 .sln文件:解決方案文件,提供了解決方案在磁盤中的位置引用,雙擊可以打開解決方案 1).csproj文件:項(xiàng)目文件,提供了項(xiàng)目文件在磁盤中的引用,雙擊可以打開項(xiàng)目 2)Program.cs: 程序入口 3)bin文件夾下包含 Debug 和 Release 兩個(gè)文件夾,分別用于存放

    2024年04月16日
    瀏覽(24)
  • .NET-4.ORM 常見(jiàn)框架EFcorn、Dapper、SqlSugar、FreeSql 和ADO.NET

    .NET-4.ORM 常見(jiàn)框架EFcorn、Dapper、SqlSugar、FreeSql 和ADO.NET

    學(xué)習(xí)參考: 1. .NET 6教程,.Net Core 2022視頻教程,楊中科主講— 以及資料參考 2. 官方文檔EF core 常用的語(yǔ)句 3..netmvc https://www.cnblogs.com/1016391912pm/p/12024671.html https://github.com/dotnet/EntityFramework.Docs/tree/main/samples/core/Querying/Overview 第一個(gè)EFCore應(yīng)用 https://docs.microsoft.com/zh-cn/ef/core/modeli

    2024年02月04日
    瀏覽(21)
  • win10系統(tǒng)切換到macOS,開發(fā)環(huán)境與軟件資源,目錄清單

    win10系統(tǒng)切換到macOS,開發(fā)環(huán)境與軟件資源,目錄清單

    1、因?yàn)榭佳凶粤?xí)室或?qū)W校圖書館,隨身攜帶游戲本(全能本)受限于 不插電源就不續(xù)航和掉性能,以及風(fēng)扇噪音非常大,以及發(fā)熱很燙 等問(wèn)題。 2、所以想考慮給主力機(jī)換個(gè)mac,目前暫定是買啦 m1pro(10+16)+16g+1t 的版本,因?yàn)樵瓉?lái)的電腦空間用了非常多,不得不刪掉一些東西

    2024年02月15日
    瀏覽(21)
  • 界面控件DevExpress WinForm——屬于WinForm組件的MVVM框架

    界面控件DevExpress WinForm——屬于WinForm組件的MVVM框架

    DevExpress WinForm擁有180+組件和UI庫(kù),能為 Windows Forms 平臺(tái)創(chuàng)建具有影響力的業(yè)務(wù)解決方案。 DevExpress WinForm 能完美構(gòu)建流暢、美觀且易于使用的應(yīng)用程序,無(wú)論是Office風(fēng)格的界面,還是分析處理大批量的業(yè)務(wù)數(shù)據(jù),它都能輕松勝任! 注意 :DevExpress WinForm v22.2已經(jīng)正式發(fā)布,新版

    2023年04月09日
    瀏覽(35)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

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

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包