npgsql 适配临时提交
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
e8db8a892c
commit
01ee530e38
|
@ -39,6 +39,27 @@
|
|||
主要为了 处理项目结束 锁库,不允许操作
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Helper.CacheKeys.SkipReadingCacheKey(System.Guid)">
|
||||
<summary>
|
||||
跳过阅片
|
||||
</summary>
|
||||
<param name="userId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Helper.CacheKeys.StartReadingTimeKey(System.Guid)">
|
||||
<summary>
|
||||
开始阅片时间
|
||||
</summary>
|
||||
<param name="userId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Helper.CacheKeys.StartRestTime(System.Guid)">
|
||||
<summary>
|
||||
开始休息时间
|
||||
</summary>
|
||||
<param name="userId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Helper.FileStoreHelper.WriteFileAsync(System.IO.Stream,System.String)">
|
||||
<summary>
|
||||
写文件导到磁盘
|
||||
|
@ -47,6 +68,12 @@
|
|||
<param name="path">文件保存路径</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:IRaCIS.Core.Application.Helper.HolidayHelper._client">
|
||||
<summary>
|
||||
github 链接:https://github.com/lanceliao/china-holiday-calender?tab=readme-ov-file
|
||||
接口请求参考文档:https://www.koudingke.cn/docs/zh-Hans/net-lib-docs/latest/RestSharp/Usage/Usage
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Helper.OSSService.UploadToOSSAsync(System.IO.Stream,System.String,System.String,System.Boolean)">
|
||||
<summary>
|
||||
oosFolderPath 不要 "/ "开头 应该: TempFolder/ChildFolder
|
||||
|
@ -1972,6 +1999,95 @@
|
|||
<param name="inDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.IVUSCalculateService.GetReadingCalculationData(IRaCIS.Core.Application.Service.Reading.Dto.GetReadingCalculationDataInDto)">
|
||||
<summary>
|
||||
获取阅片的计算数据
|
||||
</summary>
|
||||
<param name="inDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="F:IRaCIS.Core.Application.Service.ReadingCalculate.IVUSCalculateService.sODData">
|
||||
<summary>
|
||||
获取Sod的值
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:IRaCIS.Core.Application.Service.ReadingCalculate.IVUSCalculateService.iSODData">
|
||||
<summary>
|
||||
获取iSod的值
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:IRaCIS.Core.Application.Service.ReadingCalculate.IVUSCalculateService.lastVisitTaskId">
|
||||
<summary>
|
||||
上一次访视Id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:IRaCIS.Core.Application.Service.ReadingCalculate.IVUSCalculateService.firstChangeTaskId">
|
||||
<summary>
|
||||
首次转变的任务ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:IRaCIS.Core.Application.Service.ReadingCalculate.IVUSCalculateService.compareTaskList">
|
||||
<summary>
|
||||
触发任务list
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.IVUSCalculateService.GetDeleteLesionStatrIndex(IRaCIS.Core.Application.Service.Reading.Dto.DeleteReadingRowAnswerInDto)">
|
||||
<summary>
|
||||
删除病灶获取起始病灶序号(RECIST1Point1 固定是1)
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.IVUSCalculateService.GetReadingReportEvaluation(IRaCIS.Core.Application.Service.Reading.Dto.GetReadingReportEvaluationInDto)">
|
||||
<summary>
|
||||
获取阅片报告
|
||||
</summary>
|
||||
<param name="indto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.IVUSCalculateService.TestCalculate(System.Guid,System.Nullable{IRaCIS.Core.Domain.Share.QuestionType})">
|
||||
<summary>
|
||||
测试计算
|
||||
</summary>
|
||||
<param name="visitTaskId"></param>
|
||||
<param name="type"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.IVUSCalculateService.CalculateTask(IRaCIS.Core.Application.Service.Reading.Dto.CalculateTaskInDto)">
|
||||
<summary>
|
||||
计算任务
|
||||
</summary>
|
||||
<param name="inDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.IVUSCalculateService.GetReportVerify(IRaCIS.Core.Application.Service.Reading.Dto.GetReportVerifyInDto)">
|
||||
<summary>
|
||||
获取报告验证的信息(这里每个标准可能不一样 返回用object)
|
||||
</summary>
|
||||
<param name="inDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.IVUSCalculateService.ReadingCalculate(IRaCIS.Core.Application.Service.Reading.Dto.ReadingCalculateDto,System.Collections.Generic.List{IRaCIS.Core.Domain.Share.QuestionType})">
|
||||
<summary>
|
||||
自动计算
|
||||
</summary>
|
||||
<param name="inDto"></param>
|
||||
<param name="calculateType"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.IVUSCalculateService.VerifyVisitTaskQuestions(IRaCIS.Core.Application.Service.Reading.Dto.VerifyVisitTaskQuestionsInDto)">
|
||||
<summary>
|
||||
验证访视提交
|
||||
</summary>
|
||||
<param name="inDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.IVUSCalculateService.AddTaskLesionAnswerFromLastTask(IRaCIS.Core.Application.ViewModel.AddTaskLesionAnswerFromLastTaskInDto)">
|
||||
<summary>
|
||||
将上一次的访视病灶添加到这一次
|
||||
</summary>
|
||||
<param name="inDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.LuganoCalculateService.GetReadingCalculationData(IRaCIS.Core.Application.Service.Reading.Dto.GetReadingCalculationDataInDto)">
|
||||
<summary>
|
||||
获取阅片的计算数据
|
||||
|
@ -14786,7 +14902,7 @@
|
|||
<param name="inDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Application.Services.ReadingImageTaskService.#ctor(IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.NoneDicomStudy},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.VisitTask},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.Trial},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTableQuestionAnswer},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingOncologyTaskInfo},IRaCIS.Core.Application.Service.IVisitTaskHelpeService,IRaCIS.Core.Application.Service.IVisitTaskService,IRaCIS.Core.Application.Contracts.IReadingClinicalDataService,IRaCIS.Core.Application.Service.IReadingCalculateService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.SubjectVisit},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.Subject},Microsoft.Extensions.Options.IOptionsMonitor{IRaCIS.Core.Domain.Share.ServiceVerifyConfigOption},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingGlobalTaskInfo},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingCriterionPage},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTaskRelation},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingJudgeInfo},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadModule},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.DicomInstance},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.OrganInfo},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.TrialDocument},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.User},EasyCaching.Core.IEasyCachingProvider,IRaCIS.Core.Application.Service.ReadingCalculate.Interface.ILuganoCalculateService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingCustomTag},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTaskQuestionMark},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingSystemCriterionDictionary},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTrialCriterionDictionary},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.TumorAssessment_RECIST1Point1},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTableAnswerRowInfo},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTableQuestionSystem},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTableQuestionTrial},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTaskQuestionAnswer},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingQuestionCriterionTrial},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingQuestionCriterionSystem},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingQuestionSystem},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.NoneDicomStudyFile},IRaCIS.Core.Application.Service.IGeneralCalculateService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingQuestionTrial},IRaCIS.Core.Application.Interfaces.ITrialEmailNoticeConfigService)">
|
||||
<member name="M:IRaCIS.Application.Services.ReadingImageTaskService.#ctor(IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.NoneDicomStudy},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.VisitTask},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.Trial},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTableQuestionAnswer},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingOncologyTaskInfo},IRaCIS.Core.Application.Service.IVisitTaskHelpeService,IRaCIS.Core.Application.Service.IVisitTaskService,IRaCIS.Core.Application.Contracts.IReadingClinicalDataService,IRaCIS.Core.Application.Service.IReadingCalculateService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.SubjectVisit},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.Subject},Microsoft.Extensions.Options.IOptionsMonitor{IRaCIS.Core.Domain.Share.ServiceVerifyConfigOption},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingGlobalTaskInfo},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingCriterionPage},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTaskRelation},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingJudgeInfo},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadModule},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.DicomInstance},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.OrganInfo},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.TrialDocument},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.User},IRaCIS.Core.Application.Service.ReadingCalculate.Interface.ILuganoCalculateService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingCustomTag},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTaskQuestionMark},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingSystemCriterionDictionary},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTrialCriterionDictionary},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.TumorAssessment_RECIST1Point1},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTableAnswerRowInfo},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTableQuestionSystem},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTableQuestionTrial},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingTaskQuestionAnswer},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingQuestionCriterionTrial},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingQuestionCriterionSystem},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingQuestionSystem},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.NoneDicomStudyFile},IRaCIS.Core.Application.Service.IGeneralCalculateService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ReadingQuestionTrial},IRaCIS.Core.Application.Interfaces.ITrialEmailNoticeConfigService)">
|
||||
<summary>
|
||||
IR影像阅片
|
||||
</summary>
|
||||
|
@ -15378,18 +15494,13 @@
|
|||
<param name="inDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Application.Services.ReadModuleService.GetReadModuleList_new(IRaCIS.Core.Application.Service.Reading.Dto.GetReadModuleDto)">
|
||||
<member name="M:IRaCIS.Application.Services.ReadModuleService.GetReadModuleList(IRaCIS.Core.Application.Service.Reading.Dto.GetReadModuleDto)">
|
||||
<summary>
|
||||
用ef 实现之前视图的功能
|
||||
</summary>
|
||||
<param name="inQuery"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Application.Services.ReadModuleService.GetReadModuleList(IRaCIS.Core.Application.Service.Reading.Dto.GetReadModuleDto)">
|
||||
<summary>
|
||||
获取读片模块 //加了标准参数
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Application.Services.ReadModuleService.GetReadModule(IRaCIS.Core.Application.Service.Reading.Dto.GetReadModuleSingleIndto)">
|
||||
<summary>
|
||||
获取单条详情信息
|
||||
|
|
|
@ -17,6 +17,8 @@ using IRaCIS.Core.Domain.Share.Management;
|
|||
using System.Text.Json.Nodes;
|
||||
using IRaCIS.Application.Contracts;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Npgsql;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
|
@ -556,19 +558,67 @@ namespace IRaCIS.Core.Application.Service
|
|||
{
|
||||
para += para == string.Empty ? $"'{v.ToString()}'" : $",'{v.ToString()}'";
|
||||
}
|
||||
sql = $"select {ForeignKeyText} Text from [{Table}] where {ForeignKeyValue} in (@para)";
|
||||
|
||||
if (_frontAuditConfigRepository._dbContext.Database.IsSqlServer())
|
||||
{
|
||||
sql = $"select {ForeignKeyText} Text from [{Table}] where {ForeignKeyValue} in (@para)";
|
||||
|
||||
}
|
||||
else if (_frontAuditConfigRepository._dbContext.Database.IsNpgsql())
|
||||
{
|
||||
//sql = $"select {ForeignKeyText} Text from \"{Table}\" where {ForeignKeyValue} = ANY(STRING_TO_ARRAY(@para, ','))";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("不支持的数据库");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
para = $"{JsonData["item"].ToString()}";
|
||||
sql = $"select {ForeignKeyText} Text from [{Table}] where {ForeignKeyValue} = @para";
|
||||
}
|
||||
SqlParameter[] paravalue = new SqlParameter[] {
|
||||
new SqlParameter("@para",para)
|
||||
};
|
||||
ForeignKeyText = 1.ToString();
|
||||
|
||||
if (_frontAuditConfigRepository._dbContext.Database.IsSqlServer())
|
||||
{
|
||||
sql = $"select {ForeignKeyText} Text from [{Table}] where {ForeignKeyValue} = @para";
|
||||
|
||||
|
||||
}
|
||||
else if (_frontAuditConfigRepository._dbContext.Database.IsNpgsql())
|
||||
{
|
||||
//sql = $"select {ForeignKeyText} Text from \"{Table}\" where \"{ForeignKeyValue}\" = @para";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("不支持的数据库");
|
||||
}
|
||||
|
||||
|
||||
//https://learn.microsoft.com/zh-tw/ef/core/querying/sql-queries
|
||||
|
||||
}
|
||||
|
||||
if (_frontAuditConfigRepository._dbContext.Database.IsSqlServer())
|
||||
{
|
||||
|
||||
jsonDataValueDic[item.Key] = string.Join(",", _frontAuditConfigRepository._dbContext.Database.SqlQueryRaw<string>
|
||||
(sql, new SqlParameter("@para", para)).ToList());
|
||||
|
||||
}
|
||||
else if (_frontAuditConfigRepository._dbContext.Database.IsNpgsql())
|
||||
{
|
||||
|
||||
//jsonDataValueDic[item.Key] = string.Join(",", _frontAuditConfigRepository._dbContext.Database.SqlQueryRaw<string>
|
||||
// (sql, new NpgsqlParameter("@para", Guid.Parse(para))).ToList());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("不支持的数据库");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//https://learn.microsoft.com/zh-tw/ef/core/querying/sql-queries
|
||||
jsonDataValueDic[item.Key] = string.Join(",", _frontAuditConfigRepository._dbContext.Database.SqlQuery<ForeignKey>(sql, paravalue).Select(x => x.Text).ToList());
|
||||
}
|
||||
}
|
||||
return JsonConvert.SerializeObject(jsonDataValueDic);
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore.Common.Dto
|
||||
{
|
||||
public class AnswerDto
|
||||
{
|
||||
public string QuestionName { get; set; }
|
||||
|
||||
public string Answer { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
using IRaCIS.Core.Domain.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore.Common.Dto
|
||||
{
|
||||
public class AuditingDto<T>
|
||||
{
|
||||
public Type EntityType { get; set; }
|
||||
|
||||
public Expression<Func<T, DataInspection>> Expression { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -14,12 +16,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common.Dto
|
|||
|
||||
public string Identification { get; set; }
|
||||
}
|
||||
|
||||
public class TypeNameDto
|
||||
public class ForeignKey
|
||||
{
|
||||
public string TypeName { get; set; }
|
||||
|
||||
|
||||
public List<Type> Types { get; set; }
|
||||
public string Text { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore.Common.Dto
|
||||
{
|
||||
public class ForeignKey
|
||||
{
|
||||
public string Text { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore
|
||||
{
|
||||
public static class EFSqlQuery
|
||||
{
|
||||
public static IEnumerable<T> SqlQuery<T>(this DatabaseFacade facade, string sql, params object[] parameters) where T : class, new()
|
||||
{
|
||||
DataTable dt = SqlQuery(facade, sql, parameters);
|
||||
return dt.ToEnumerable<T>();
|
||||
}
|
||||
|
||||
public static IEnumerable<T> ToEnumerable<T>(this DataTable dt) where T : class, new()
|
||||
{
|
||||
PropertyInfo[] propertyInfos = typeof(T).GetProperties();
|
||||
T[] ts = new T[dt.Rows.Count];
|
||||
int i = 0;
|
||||
foreach (DataRow row in dt.Rows)
|
||||
{
|
||||
T t = new T();
|
||||
foreach (PropertyInfo p in propertyInfos)
|
||||
{
|
||||
if (dt.Columns.IndexOf(p.Name) != -1 && row[p.Name] != DBNull.Value)
|
||||
p.SetValue(t, row[p.Name], null);
|
||||
}
|
||||
ts[i] = t;
|
||||
i++;
|
||||
}
|
||||
return ts;
|
||||
}
|
||||
|
||||
public static DataTable SqlQuery(this DatabaseFacade facade, string sql, params object[] parameters)
|
||||
{
|
||||
DbCommand cmd = CreateCommand(facade, sql, out DbConnection conn, parameters);
|
||||
DbDataReader reader = cmd.ExecuteReader();
|
||||
DataTable dt = new DataTable();
|
||||
dt.Load(reader);
|
||||
reader.Close();
|
||||
conn.Close();
|
||||
return dt;
|
||||
}
|
||||
|
||||
private static DbCommand CreateCommand(DatabaseFacade facade, string sql, out DbConnection dbConn, params object[] parameters)
|
||||
{
|
||||
DbConnection conn = facade.GetDbConnection();
|
||||
dbConn = conn;
|
||||
conn.Open();
|
||||
DbCommand cmd = conn.CreateCommand();
|
||||
if (facade.IsRelational())
|
||||
{
|
||||
cmd.CommandText = sql;
|
||||
CombineParams(ref cmd, parameters);
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
|
||||
private static void CombineParams(ref DbCommand command, params object[] parameters)
|
||||
{
|
||||
if (parameters != null)
|
||||
{
|
||||
foreach (SqlParameter parameter in parameters)
|
||||
{
|
||||
if (!parameter.ParameterName.Contains("@"))
|
||||
parameter.ParameterName = $"@{parameter.ParameterName}";
|
||||
command.Parameters.Add(parameter);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue