I have this code on a Blazor Server-Side page:
protected override async Task OnInitializedAsync()
{
try
{
_model = await BudgetReleaseRequestProviderService.GetMeetingById(MeetingId);
var meetingRequestsIds = await BudgetReleaseRequestProviderService.GetMeetingDetailsForMeeting(_model.Id);
var selectedRequestIds = meetingRequestsIds.Select(s => s.RequestId).ToArray();
var meetingRequests = (await BudgetReleaseRequestProviderService.GetAllRequests())
.Where(w => selectedRequestIds.Contains(w.Id)).ToList();
_requestsData = new List<MeetingRequestActionViewModel>(meetingRequests.Cast<MeetingRequestActionViewModel>());
}
catch (Exception e)
{
LoadingStatus = $"Error while loading meeting #{MeetingId}. Error: {e.Message}";
Console.WriteLine(e);
}
}
There is no error but when I build, I get these errors:
Errors:
- CS1662 Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type
- CS0131 The left-hand side of an assignment must be a variable, property or indexer
These errors are on the .g.cs
file of the page. I cannot amke sense of that file. I have a Contains call in my Linq and that is the closest I have reached to troubleshooting.
Classes:
public class MeetingRequestActionViewModel: BudgetReleaseRequestViewModel
{}
public partial class BudgetReleaseRequestViewModel
{
public long Id { get; set; }
[Required]
[Display(Name = "Description")]
public string Description { get; set; }
[Required]
[Display(Name = "Amount")]
[DataType(DataType.Currency)]
public decimal Amount { get; set; }
public string RequesterId { get; set; }
[Display(Name = "Budget Owner")]
public string BudgetOwnerId { get; set; }
[Required]
[Display(Name = "Submission Date")]
[DateTodayAndOnwards(ErrorMessage = "This date cannot be before today.")]
[DataType(DataType.Date)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "dd/MMM/yyyy")]
public DateTime SubmissionDate { get; set; }
}
For the sake of this page only, I decided to create a view model based on an existing one and add the two extrs required fields. That's why there is a converstion.
IEnumerable<>
. Solved by changing toList<>
. – Parthia