From a9416cc212104e8cc7f6eb3c6e8beef4e316c5e9 Mon Sep 17 00:00:00 2001 From: skx <610262374@qq.com> Date: Wed, 21 Oct 2020 15:37:48 +0800 Subject: [PATCH] virtual --- Src/Asp.Net/SqlSugar/SimpleClient.cs | 88 ++++++++++++++-------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/SimpleClient.cs b/Src/Asp.Net/SqlSugar/SimpleClient.cs index 0e9e9086d..511d39c4b 100644 --- a/Src/Asp.Net/SqlSugar/SimpleClient.cs +++ b/Src/Asp.Net/SqlSugar/SimpleClient.cs @@ -66,212 +66,212 @@ namespace SqlSugar #endregion #region Method - public T GetById(dynamic id) + public virtual T GetById(dynamic id) { return Context.Queryable().InSingle(id); } - public List GetList() + public virtual List GetList() { return Context.Queryable().ToList(); } - public List GetList(Expression> whereExpression) + public virtual List GetList(Expression> whereExpression) { return Context.Queryable().Where(whereExpression).ToList(); } - public T GetSingle(Expression> whereExpression) + public virtual T GetSingle(Expression> whereExpression) { return Context.Queryable().Single(whereExpression); } - public List GetPageList(Expression> whereExpression, PageModel page) + public virtual List GetPageList(Expression> whereExpression, PageModel page) { int count = 0; var result = Context.Queryable().Where(whereExpression).ToPageList(page.PageIndex, page.PageSize, ref count); page.PageCount = count; return result; } - public List GetPageList(Expression> whereExpression, PageModel page, Expression> orderByExpression = null, OrderByType orderByType = OrderByType.Asc) + public virtual List GetPageList(Expression> whereExpression, PageModel page, Expression> orderByExpression = null, OrderByType orderByType = OrderByType.Asc) { int count = 0; var result = Context.Queryable().OrderByIF(orderByExpression != null, orderByExpression, orderByType).Where(whereExpression).ToPageList(page.PageIndex, page.PageSize, ref count); page.PageCount = count; return result; } - public List GetPageList(List conditionalList, PageModel page) + public virtual List GetPageList(List conditionalList, PageModel page) { int count = 0; var result = Context.Queryable().Where(conditionalList).ToPageList(page.PageIndex, page.PageSize, ref count); page.PageCount = count; return result; } - public List GetPageList(List conditionalList, PageModel page, Expression> orderByExpression = null, OrderByType orderByType = OrderByType.Asc) + public virtual List GetPageList(List conditionalList, PageModel page, Expression> orderByExpression = null, OrderByType orderByType = OrderByType.Asc) { int count = 0; var result = Context.Queryable().OrderByIF(orderByExpression != null, orderByExpression, orderByType).Where(conditionalList).ToPageList(page.PageIndex, page.PageSize, ref count); page.PageCount = count; return result; } - public bool IsAny(Expression> whereExpression) + public virtual bool IsAny(Expression> whereExpression) { return Context.Queryable().Where(whereExpression).Any(); } - public int Count(Expression> whereExpression) + public virtual int Count(Expression> whereExpression) { return Context.Queryable().Where(whereExpression).Count(); } - public bool Insert(T insertObj) + public virtual bool Insert(T insertObj) { return this.Context.Insertable(insertObj).ExecuteCommand() > 0; } - public int InsertReturnIdentity(T insertObj) + public virtual int InsertReturnIdentity(T insertObj) { return this.Context.Insertable(insertObj).ExecuteReturnIdentity(); } - public bool InsertRange(T[] insertObjs) + public virtual bool InsertRange(T[] insertObjs) { return this.Context.Insertable(insertObjs).ExecuteCommand() > 0; } - public bool InsertRange(List insertObjs) + public virtual bool InsertRange(List insertObjs) { return this.Context.Insertable(insertObjs).ExecuteCommand() > 0; } - public bool Update(T updateObj) + public virtual bool Update(T updateObj) { return this.Context.Updateable(updateObj).ExecuteCommand() > 0; } - public bool UpdateRange(T[] updateObjs) + public virtual bool UpdateRange(T[] updateObjs) { return this.Context.Updateable(updateObjs).ExecuteCommand() > 0; } - public bool UpdateRange(List updateObjs) + public virtual bool UpdateRange(List updateObjs) { return this.Context.Updateable(updateObjs).ExecuteCommand() > 0; } - public bool Update(Expression> columns, Expression> whereExpression) + public virtual bool Update(Expression> columns, Expression> whereExpression) { return this.Context.Updateable().SetColumns(columns).Where(whereExpression).ExecuteCommand() > 0; } - public bool Delete(T deleteObj) + public virtual bool Delete(T deleteObj) { return this.Context.Deleteable().Where(deleteObj).ExecuteCommand() > 0; } - public bool Delete(Expression> whereExpression) + public virtual bool Delete(Expression> whereExpression) { return this.Context.Deleteable().Where(whereExpression).ExecuteCommand() > 0; } - public bool DeleteById(dynamic id) + public virtual bool DeleteById(dynamic id) { return this.Context.Deleteable().In(id).ExecuteCommand() > 0; } - public bool DeleteByIds(dynamic[] ids) + public virtual bool DeleteByIds(dynamic[] ids) { return this.Context.Deleteable().In(ids).ExecuteCommand() > 0; } #endregion #region Async Method - public Task GetByIdAsync(dynamic id) + public virtual Task GetByIdAsync(dynamic id) { return Context.Queryable().InSingleAsync(id); } - public Task> GetListAsync() + public virtual Task> GetListAsync() { return Context.Queryable().ToListAsync(); } - public Task> GetListAsync(Expression> whereExpression) + public virtual Task> GetListAsync(Expression> whereExpression) { return Context.Queryable().Where(whereExpression).ToListAsync(); } - public Task GetSingleAsync(Expression> whereExpression) + public virtual Task GetSingleAsync(Expression> whereExpression) { return Context.Queryable().SingleAsync(whereExpression); } - public Task> GetPageListAsync(Expression> whereExpression, PageModel page) + public virtual Task> GetPageListAsync(Expression> whereExpression, PageModel page) { RefAsync count = 0; var result = Context.Queryable().Where(whereExpression).ToPageListAsync(page.PageIndex, page.PageSize, count); page.PageCount = count; return result; } - public Task> GetPageListAsync(Expression> whereExpression, PageModel page, Expression> orderByExpression = null, OrderByType orderByType = OrderByType.Asc) + public virtual Task> GetPageListAsync(Expression> whereExpression, PageModel page, Expression> orderByExpression = null, OrderByType orderByType = OrderByType.Asc) { RefAsync count = 0; var result = Context.Queryable().OrderByIF(orderByExpression != null, orderByExpression, orderByType).Where(whereExpression).ToPageListAsync(page.PageIndex, page.PageSize, count); page.PageCount = count; return result; } - public Task> GetPageListAsync(List conditionalList, PageModel page) + public virtual Task> GetPageListAsync(List conditionalList, PageModel page) { RefAsync count = 0; var result = Context.Queryable().Where(conditionalList).ToPageListAsync(page.PageIndex, page.PageSize, count); page.PageCount = count; return result; } - public Task> GetPageListAsync(List conditionalList, PageModel page, Expression> orderByExpression = null, OrderByType orderByType = OrderByType.Asc) + public virtual Task> GetPageListAsync(List conditionalList, PageModel page, Expression> orderByExpression = null, OrderByType orderByType = OrderByType.Asc) { RefAsync count = 0; var result = Context.Queryable().OrderByIF(orderByExpression != null, orderByExpression, orderByType).Where(conditionalList).ToPageListAsync(page.PageIndex, page.PageSize, count); page.PageCount = count; return result; } - public Task IsAnyAsync(Expression> whereExpression) + public virtual Task IsAnyAsync(Expression> whereExpression) { return Context.Queryable().Where(whereExpression).AnyAsync(); } - public Task CountAsync(Expression> whereExpression) + public virtual Task CountAsync(Expression> whereExpression) { return Context.Queryable().Where(whereExpression).CountAsync(); } - public async Task InsertAsync(T insertObj) + public virtual async Task InsertAsync(T insertObj) { return await this.Context.Insertable(insertObj).ExecuteCommandAsync() > 0; } - public Task InsertReturnIdentityAsync(T insertObj) + public virtual Task InsertReturnIdentityAsync(T insertObj) { return this.Context.Insertable(insertObj).ExecuteReturnIdentityAsync(); } - public async Task InsertRangeAsync(T[] insertObjs) + public virtual async Task InsertRangeAsync(T[] insertObjs) { return await this.Context.Insertable(insertObjs).ExecuteCommandAsync() > 0; } - public async Task InsertRangeAsync(List insertObjs) + public virtual async Task InsertRangeAsync(List insertObjs) { return await this.Context.Insertable(insertObjs).ExecuteCommandAsync() > 0; } - public async Task UpdateAsync(T updateObj) + public virtual async Task UpdateAsync(T updateObj) { return await this.Context.Updateable(updateObj).ExecuteCommandAsync() > 0; } - public async Task UpdateRangeAsync(T[] updateObjs) + public virtual async Task UpdateRangeAsync(T[] updateObjs) { return await this.Context.Updateable(updateObjs).ExecuteCommandAsync() > 0; } - public async Task UpdateRangeAsync(List updateObjs) + public virtual async Task UpdateRangeAsync(List updateObjs) { return await this.Context.Updateable(updateObjs).ExecuteCommandAsync() > 0; } - public async Task UpdateAsync(Expression> columns, Expression> whereExpression) + public virtual async Task UpdateAsync(Expression> columns, Expression> whereExpression) { return await this.Context.Updateable().SetColumns(columns).Where(whereExpression).ExecuteCommandAsync() > 0; } - public async Task DeleteAsync(T deleteObj) + public virtual async Task DeleteAsync(T deleteObj) { return await this.Context.Deleteable().Where(deleteObj).ExecuteCommandAsync() > 0; } - public async Task DeleteAsync(Expression> whereExpression) + public virtual async Task DeleteAsync(Expression> whereExpression) { return await this.Context.Deleteable().Where(whereExpression).ExecuteCommandAsync() > 0; } - public async Task DeleteByIdAsync(dynamic id) + public virtual async Task DeleteByIdAsync(dynamic id) { return await this.Context.Deleteable().In(id).ExecuteCommand() > 0; } - public async Task DeleteByIdsAsync(dynamic[] ids) + public virtual async Task DeleteByIdsAsync(dynamic[] ids) { return await this.Context.Deleteable().In(ids).ExecuteCommandAsync() > 0; }