我有Guid,我用
标记无效public struct abc
{
public Guid Id { get; set; }
public Guid? PreviousCalculatedId { get; set; }
public Guid? NextCalculatedId { get; set; }
}
但是我在PreviousCalculatedId和NextCalculatedId的LINQ查询上遇到构建错误
错误
error is cannot implicitly convert type system.Guid to bool
var answerDataView = (from Calc in dbContext.Calculation
where Calc .abcId == abcId && Calc .Id == GivenCalcId
select new abc
{
Id = mylist.listedItemId,
Text = Calc .Value,
NextCalculatedId? = sortedAnswerList.ItemOnRight[0],
PreviousCalculatedId? = sortedAnswerList.ItemOnLeft.ElementAt(0),
});
答案 0 :(得分:2)
试试这个,
var answerDataView = (from Calc in dbContext.Calculation
where Calc .abcId == abcId && Calc .Id == GivenCalcId
select new abc
{
Id = mylist.listedItemId,
Text = Calc .Value,
NextCalculatedId = sortedAnswerList.ItemOnRight[0] ?? null,
PreviousCalculatedId = sortedAnswerList.ItemOnLeft.ElementAt(0) ?? null,
});
并且