Synthax Error with Linq

sblb 1,166 Reputation points
2021-11-29T17:10:52.753+00:00

Hi;
I wrote Linq code below and there is a synthax error I didn't see where?

public IActionResult RevenueByMonth()  
        {  
            var result = context.Developers  
                                 .Where(opportunity => opportunity.Statut == "Closed")  
                                 .Where(opportunity => opportunity.DateSolde >= new DateTime(_currentYear, 1, 1)  
                                        && opportunity => opportunity.DateSolde <= new DateTime(_currentYear, 12, 31))  
                                .GroupBy(opportunity => opportunity.DateSolde.Month)  
                                .OrderBy(opportunity => opportunity.Key)  
                                .Select(group => new  
                                 {  
                                     Month = GetMonthAsText(group.Key, _currentYear),  
                                     Revenue = group.Count()      
                                 })  
                               .ToList();  
           return Ok(JsonSerializer.Serialize(result, new JsonSerializerOptions  
            {  
                PropertyNamingPolicy = null  
            }));  
        }  

The problem is here :
153423-capture.png

Do you have an idea because I don't see it?

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,390 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,248 questions
0 comments No comments
{count} votes

1 additional answer

Sort by: Most helpful
  1. AgaveJoe 26,201 Reputation points
    2021-11-29T17:59:58.137+00:00

    Try...

    .Where(opportunity => opportunity.DateSolde >= new DateTime(_currentYear, 1, 1)
         && opportunity.DateSolde <= new DateTime(_currentYear, 12, 31))
    
    2 people found this answer helpful.