修改了CopyTo方法,使用反射可以将列表的内容也可以复制
This commit is contained in:
@@ -3,11 +3,17 @@ using PMSWPF.Excptions;
|
||||
using PMSWPF.Extensions;
|
||||
using PMSWPF.Helper;
|
||||
using PMSWPF.Models;
|
||||
using SqlSugar;
|
||||
|
||||
namespace PMSWPF.Data.Repositories;
|
||||
|
||||
public class DevicesRepositories : BaseRepositories
|
||||
public class DevicesRepositories
|
||||
{
|
||||
private SqlSugarClient _db;
|
||||
public DevicesRepositories()
|
||||
{
|
||||
_db = DbContext.GetInstance();
|
||||
}
|
||||
public async Task<bool> Add(Device device)
|
||||
{
|
||||
var exist = await _db.Queryable<DbDevice>().Where(d => d.Name == device.Name).FirstAsync();
|
||||
@@ -30,8 +36,7 @@ public class DevicesRepositories : BaseRepositories
|
||||
var devices = new List<Device>();
|
||||
foreach (var dbDevice in dlist)
|
||||
{
|
||||
var device = dbDevice.NewTo<Device>();
|
||||
device.VariableTables = CovertHelper.ConvertList<DbVariableTable, VariableTable>(dbDevice.VariableTables);
|
||||
var device = dbDevice.CopyTo<Device>();
|
||||
devices.Add(device);
|
||||
}
|
||||
|
||||
|
||||
25
Data/Repositories/MenuRepositories.cs
Normal file
25
Data/Repositories/MenuRepositories.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Windows.Controls;
|
||||
using PMSWPF.Data.Entities;
|
||||
using SqlSugar;
|
||||
|
||||
namespace PMSWPF.Data.Repositories;
|
||||
|
||||
public class MenuRepositories
|
||||
{
|
||||
private readonly SqlSugarClient _db;
|
||||
|
||||
public MenuRepositories()
|
||||
{
|
||||
_db=DbContext.GetInstance();
|
||||
}
|
||||
|
||||
public async Task<List<DbMenu>> GetMenu()
|
||||
{
|
||||
return await _db.Queryable<DbMenu>().ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<int> AddMenu(DbMenu dbMenu)
|
||||
{
|
||||
return await _db.Insertable<DbMenu>(dbMenu).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user