gpt4 book ai didi

linq-to-sql - 如何在 linq pad 中执行左连接 -

转载 作者:行者123 更新时间:2023-12-01 02:35:36 26 4
gpt4 key购买 nike

如何让 linq pad 运行我的左连接,如下所示?

var query = 
from s in db.CDBLogsHeaders
.OrderByDescending(g => g.LogDateTime)
from sc in db.StyleColors
.Where(stylecolor => stylecolor.id == (int?)s.StyleColorID)
.DefaultIfEmpty()
from c in db.StyleHeaders
.Where(styleHeader => styleHeader.id == (int?)s.StyleHeaderID)
.DefaultIfEmpty()
select new
{
CDBLogsHeaderId = s.Id,
Merchandiser = c.Merchandiser,
Material = s.Material,
Season = s.Season,
LogsHeaderLogType = s.LogType,
PushFromTo = s.PushFromTo,
LinePlan = s.LinePlan,
QuikRefNumber = s.QuikRefNumber,
PLMOrigin = s.PLM_Origin,
SeasonOriginal = c.SeasonOriginal,
SeasonCurrent = c.SeasonCurrent,
StyleHeaderId = c.Id,
StyleCode = c.StyleCode,
StyleColorsColorCode = sc.ColorCode
};

query.Dump();

linq pad 创建的 sql 在 Management Studio 中完美运行,但 linq-pad 不显示任何行并给出此错误

InvalidOperationException: The null value cannot be assigned to a member with type System.Int32 which is a non-nullable value type.



如何让 linqpad 工作以便我可以玩它?

最佳答案

在您的匿名类型中,确保您的整数返回整数。

改变

StyleHeaderId = c.Id,


StyleHeaderId = (c.Id == null ? 0 : c.Id),

关于linq-to-sql - 如何在 linq pad 中执行左连接 -,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10435938/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com