Reputation: 5075
I have Guid which I mark null-able by
public struct abc
{
public Guid Id { get; set; }
public Guid? PreviousCalculatedId { get; set; }
public Guid? NextCalculatedId { get; set; }
}
But I am getting build error on LINQ query for PreviousCalculatedId and NextCalculatedId
error
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),
});
Upvotes: 0
Views: 674
Reputation: 764
Try this,
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,
});
And
Upvotes: 2