重构代码:SQLite工程实体类使用DataAccess类中的父类
This commit is contained in:
parent
174638983d
commit
c4195adb6b
|
@ -67,13 +67,13 @@ namespace Bootstrap.DataAccess.SQLite
|
|||
public override IEnumerable<DataAccess.Exceptions> RetrieveExceptions()
|
||||
{
|
||||
string sql = "select * from Exceptions where LogTime > datetime('now', 'localtime', '-7 day') order by LogTime desc";
|
||||
List<Exceptions> exceptions = new List<Exceptions>();
|
||||
List<DataAccess.Exceptions> exceptions = new List<DataAccess.Exceptions>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
exceptions.Add(new Exceptions()
|
||||
exceptions.Add(new DataAccess.Exceptions()
|
||||
{
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
AppDomainName = (string)reader[1],
|
||||
|
|
|
@ -21,13 +21,13 @@ namespace Bootstrap.DataAccess.SQLite
|
|||
public override IEnumerable<DataAccess.Log> RetrieveLogs(string tId = null)
|
||||
{
|
||||
string sql = "select * from Logs where LogTime > datetime('now', 'localtime', '-7 day')";
|
||||
List<Log> logs = new List<Log>();
|
||||
List<DataAccess.Log> logs = new List<DataAccess.Log>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
logs.Add(new Log()
|
||||
logs.Add(new DataAccess.Log()
|
||||
{
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
CRUD = (string)reader[1],
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace Bootstrap.DataAccess.SQLite
|
|||
try
|
||||
{
|
||||
//删除菜单角色表该角色所有的菜单
|
||||
string sql = "delete from NavigationRole where RoleID=@RoleID";
|
||||
string sql = $"delete from NavigationRole where RoleID = {roleId}";
|
||||
using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
|
||||
{
|
||||
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
||||
|
|
|
@ -19,14 +19,14 @@ namespace Bootstrap.DataAccess.SQLite
|
|||
protected override IEnumerable<DataAccess.Message> RetrieveMessages(string userName)
|
||||
{
|
||||
string sql = "select m.*, d.Name, ifnull(i.Code + u.Icon, '~/images/uploader/default.jpg'), u.DisplayName from [Messages] m left join Dicts d on m.Label = d.Code and d.Category = '消息标签' and d.Define = 0 left join Dicts i on i.Category = '头像地址' and i.Name = '头像路径' and i.Define = 0 inner join Users u on m.[From] = u.UserName where [To] = @UserName or [From] = @UserName order by m.SendTime desc";
|
||||
List<Message> messages = new List<Message>();
|
||||
List<DataAccess.Message> messages = new List<DataAccess.Message>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@UserName", userName));
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
messages.Add(new Message()
|
||||
messages.Add(new DataAccess.Message()
|
||||
{
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
Title = (string)reader[1],
|
||||
|
|
|
@ -15,13 +15,13 @@ namespace Bootstrap.DataAccess.SQLite
|
|||
public override IEnumerable<DataAccess.Task> RetrieveTasks()
|
||||
{
|
||||
string sql = "select t.*, u.DisplayName from Tasks t inner join Users u on t.UserName = u.UserName order by AssignTime desc limit 1000";
|
||||
List<Task> tasks = new List<Task>();
|
||||
List<DataAccess.Task> tasks = new List<DataAccess.Task>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
tasks.Add(new Task()
|
||||
tasks.Add(new DataAccess.Task()
|
||||
{
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
TaskName = (string)reader[1],
|
||||
|
|
Loading…
Reference in New Issue