Florin M.
Florin M.

Reputation: 2169

The left-hand side of an assignment must be a variable property or indexer

Code:

public static List<ExpressionListDictionary> GetAmounts()
{
    using (DataAccessAdapter adapter = new DataAccessAdapter())
    {
        LinqMetaData meta = new LinqMetaData(adapter);
        var now = DateTime.Now;
        var endDate = now;
        var startDate = now.AddMonths(-3);

        var datas = ( from test in meta.Test
                      where test.DateCreated >= startDate && test.DateCreated <= endDate && test.ViaTo > 0 && test.Cancelled == 0 
                      select MonthOfYear(test.DateCreated)); // how can I get the month name correctly?              
    }  
} 

Cancelled is bool TestEntity.Cancelled

I'm getting the error at the where statement. How can I fixed it?

Upvotes: 0

Views: 1180

Answers (3)

Ehsan Sajjad
Ehsan Sajjad

Reputation: 62488

Your statement after last && is not right you need == for comparing instead of =

= do assignment in C# that's why its complaining:

&& test.Cancelled == 0

Update:

As Cancelled is bool you have to put true or false in comparison

Upvotes: 3

user3667171
user3667171

Reputation:

You should correct this:

&& test.Cancelled = 0

Into the following:

&& !test.Cancelled

Upvotes: 1

Rahul Singh
Rahul Singh

Reputation: 21815

As per your comment, since Cancelled is a boolean property why you are trying to compare it with 0? You can simply do this:-

 && test.Cancelled

Or && !test.Cancelled for negative case.

Upvotes: 1

Related Questions