原报错代码:
public WebResponseContent GetNewProductProductionSchedulingList(ApiNewProductProductionSchedulingQueryInput apiNewProductProductionSchedulingQueryInput)
{
WebResponseContent<List<ApiNewProductProductionSchedulingOutPut>> result = new WebResponseContent<List<ApiNewProductProductionSchedulingOutPut>>();
var resultTemp = repository.FindAsIQueryable(f => f.IsDeleted == 0).Select(f => new ApiNewProductProductionSchedulingOutPut
{
Id=f.Id,
ManagementNo = f.ManagementNo,
CreateTime = f.CreateTime,
ModifyTime = f.ModifyTime,
State = f.State,
CreatorCode = f.CreatorCode
}).Distinct();
//条件
if (apiNewProductProductionSchedulingQueryInput.ManagementNo != null)//管理编号
{
resultTemp = resultTemp.Where(f => f.ManagementNo == apiNewProductProductionSchedulingQueryInput.ManagementNo);
}
if (apiNewProductProductionSchedulingQueryInput.State != null)//排产状态(0=待排产1=排产中2=已完成)
{
resultTemp = resultTemp.Where(f => f.State == apiNewProductProductionSchedulingQueryInput.State);
}
if (apiNewProductProductionSchedulingQueryInput.CreatorCode != null)//员工
{
resultTemp = resultTemp.Where(f => f.CreatorCode == apiNewProductProductionSchedulingQueryInput.CreatorCode);
}
return result.OK("获取成功", resultTemp.ToList());
}
原ef翻译:
SELECT DISTINCT [b].[management_no] AS [ManagementNo], [b].[create_time] AS [CreateTime], [b].[modify_time] AS [ModifyTime], [b].[state] AS [State], [b].[creator_code] AS [CreatorCode]
FROM [biz_new_product_production_scheduling] AS [b]
WHERE (([b].[is_deleted] = 0) AND ([b].[is_deleted] = 0)) AND ([b].[management_no] = @__apiNewProductProductionSchedulingQueryInput_ManagementNo_0)
ORDER BY (SELECT 1)
OFFSET 0 ROWS FETCH NEXT @__p_1 ROWS ONLY
修改后代码:
public WebResponseContent GetNewProductProductionSchedulingList(ApiNewProductProductionSchedulingQueryInput apiNewProductProductionSchedulingQueryInput)
{
var pageIndex = apiNewProductProductionSchedulingQueryInput.PageIndex <= 0 ? 1 : apiNewProductProductionSchedulingQueryInput.PageIndex;
var pagesize = apiNewProductProductionSchedulingQueryInput.PageSize <= 0 ? 10 : apiNewProductProductionSchedulingQueryInput.PageSize;
WebResponseContent<List<ApiNewProductProductionSchedulingOutPut>> result = new WebResponseContent<List<ApiNewProductProductionSchedulingOutPut>>();
var resultTemp = repository.FindAsIQueryable(f => f.IsDeleted == 0).Select(f => new ApiNewProductProductionSchedulingOutPut
{
ManagementNo = f.ManagementNo,
CreateTime = f.CreateTime,
ModifyTime = f.ModifyTime,
State = f.State,
CreatorCode = f.CreatorCode
});
//条件
if (apiNewProductProductionSchedulingQueryInput.ManagementNo != null)//管理编号
{
resultTemp = resultTemp.Where(f => f.ManagementNo == apiNewProductProductionSchedulingQueryInput.ManagementNo);
}
if (apiNewProductProductionSchedulingQueryInput.State != null)//排产状态
{
resultTemp = resultTemp.Where(f => f.State == apiNewProductProductionSchedulingQueryInput.State);
}
if (apiNewProductProductionSchedulingQueryInput.CreatorCode != null)//员工
{
resultTemp = resultTemp.Where(f => f.CreatorCode == apiNewProductProductionSchedulingQueryInput.CreatorCode);
}
resultTemp = resultTemp.Distinct().OrderBy(f => f.CreateTime).Skip((pageIndex - 1) * pagesize).Take(pagesize);
return result.OK("获取成功", resultTemp.ToList());
}
修改后ef翻译:
SELECT [t].[management_no] AS [ManagementNo], [t].[create_time] AS [CreateTime], [t].[modify_time] AS [ModifyTime], [t].[state] AS [State], [t].[creator_code] AS [CreatorCode]
FROM (
SELECT DISTINCT [b].[management_no], [b].[create_time], [b].[modify_time], [b].[state], [b].[creator_code]
FROM [biz_new_product_production_scheduling] AS [b]
WHERE (([b].[is_deleted] = 0) AND ([b].[is_deleted] = 0)) AND ([b].[management_no] = @__apiNewProductProductionSchedulingQueryInput_ManagementNo_0)
) AS [t]
ORDER BY [t].[create_time]
OFFSET 0 ROWS FETCH NEXT @__p_1 ROWS ONLY```
值得注意的是无论ORDER BY多少字段 被翻译的都只有最后一个ORDER
BY的字段,(有机会确认下)要想正确被翻译应该用ThenByDescending() 和ThenBy()
处理Bug的具体步骤
- 重现BUG
- 确定发生BUG的过程时都做了哪些动作
- 桌面检查:把自己的脑子作为CPU,运行从开始操作到出现BUG的操作、处理的数据,分析出现问题的原因
- 调试:确定问题出现的原因
- 确定解决方案
- 修复BUG
- 回归测试:确定已BUG已修复并没引入新问题
没有粉丝,没有评论,甚至连读者都没有。因为自己写的烂,因为自己水平有限,所以自己的作品一经发出就石沉大海了,得不到任何的回信,就好像自己写的东西是给自己看的。自己的作品怎么看都好像不够完美,全身的毛病,所以读者不喜欢也很正常对吧!
其实最让我开心的是有些读者们夸我文笔不错,或许是有人第一次这样夸我的缘故吧!又或许是我写的东西没什么人认可,我感受到了一种前所未有的激动,对于未来的憧憬,对自己写下去的动力。
因为有你们,我的写作之路才不孤独,因为有你们,我才能坚持到现在,如果有一天我真的写出圈了,或许我们可以整个交流会之类的,到时候促膝长谈。
“书山有路勤为径,学海无涯苦作舟。”写作苦是苦了点,整得我差点就想放弃了,不过还好有你们。我也不急着成功,因为没有个几十年如一日的坚持,哪能轻易成功?
茫茫文海无人意,天下有君识吾心。文海很孤独,但是有诸君,便足以令我至千里。