62 lines
1.6 KiB
C#
62 lines
1.6 KiB
C#
using DeviceRepair.DataAccess.Data;
|
|
using DeviceRepair.Models;
|
|
using DeviceRepair.Utils;
|
|
using NLog;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
|
|
namespace DeviceRepair.DataAccess.SysCommon
|
|
{
|
|
public class CustomFieldDa : BaseDa
|
|
{
|
|
private static readonly Logger log = LogManager.GetCurrentClassLogger();
|
|
|
|
public CustomFieldDa() : base()
|
|
{
|
|
|
|
}
|
|
|
|
public CustomFieldDa(IDictionary<string, string> apiParams) : base(apiParams)
|
|
{
|
|
|
|
}
|
|
|
|
public DataSet GetDatas()
|
|
{
|
|
DataSet dsDatas = new DataSet("Datas");
|
|
string[] FieldCodes = new string[] { };
|
|
try
|
|
{
|
|
if (ApiParameters.ContainsKey("FieldCode"))
|
|
{
|
|
FieldCodes = ApiParameters["FieldCode"].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
|
}
|
|
|
|
var exp = Expressionable.Create<FieldsInfo>()
|
|
.AndIF(FieldCodes.Length > 0, x => SqlFunc.ContainsArray(FieldCodes, x.FieldCode)).ToExpression();//拼接表达式
|
|
|
|
List<FieldsInfo> Datas = devMain.Queryable<FieldsInfo>().Where(exp).ToList();
|
|
DataTable table = Datas.ToDataTable();
|
|
dsDatas.Tables.Add(table);
|
|
|
|
return dsDatas;
|
|
}
|
|
catch (SqlException sqlEx)
|
|
{
|
|
throw sqlEx;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//FieldCode
|
|
}
|
|
}
|