43 lines
1.0 KiB
C#
43 lines
1.0 KiB
C#
using SqlSugar;
|
|||
|
|
using System;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Data;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Linq.Expressions;
|
||
|
|
using System.Text;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
|
||
|
|
namespace JinYuan.DAL.Service
|
||
|
|
{
|
||
|
|
public class BaseService<T> : IBaseService<T> where T : class, new()
|
||
|
|
{
|
||
|
|
protected readonly ISqlSugarClient _db;
|
||
|
|
public BaseService(ISqlSugarClient db) { _db = db; }
|
||
|
|
|
||
|
|
public virtual bool Add(T model)
|
||
|
|
{
|
||
|
|
return _db.Insertable(model).ExecuteCommand() > 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
public virtual DataTable GetDataTable()
|
||
|
|
{
|
||
|
|
return _db.Queryable<T>().ToDataTable();
|
||
|
|
}
|
||
|
|
|
||
|
|
public virtual List<T> GetList()
|
||
|
|
{
|
||
|
|
return _db.Queryable<T>().ToList();
|
||
|
|
}
|
||
|
|
|
||
|
|
public virtual bool SoftDelete(int id)
|
||
|
|
{
|
||
|
|
return _db.Deleteable<T>().In(id).ExecuteCommand() > 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
public virtual bool Update(T model)
|
||
|
|
{
|
||
|
|
return _db.Updateable(model).ExecuteCommand() > 0;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|