3

Cannot convert lambda expression to type 'bool' because it is not a delegate type

When comparing 2 integers in the if statement "if (UserLevelID => dbMinimunlevelID)"

How can I compare a variable that holds a count with another integer?

 //Check if user has enough credits to create ClassCharacter       
        public bool CheckMinimunCreditforClassCharacter(Guid UserID, int ClassCharacterID, int Levelid)
        {

        bool Results = true;

        //Check Character Creation Rules
        int dbMinimunlevelID = 0;
        bool AdditionalCharactersRequired = false;
        int AdditionalCharactersPoints = 0;

        var query = (from o in db.ClassCharacters
                     where o.ClassCharacterID == ClassCharacterID
                     select o);   

        foreach (var v in query)
        {
            dbMinimunlevelID = v.MinimumPoints;
            AdditionalCharactersRequired = v.AdditionalCharactersRequired;
            AdditionalCharactersPoints = v.AdditionalCharactersPoints;
        }

        if (dbMinimunlevelID > 0)
        {
            //Check User existing Characters
            int UserLevelID = db.Characters.Where(o => o.UserId == UserID)
                         .Max(o => o.LevelID);

            //************ Here is where the error appears
            if (UserLevelID => dbMinimunlevelID)
            {
                Results = true;
            }
            else
            {
                Results = false;
            }

        }

        return Results;
    }
MataHari
  • 318
  • 3
  • 6
  • 15

2 Answers2

10

Replace:

if (UserLevelID => dbMinimunlevelID)

with:

if (UserLevelID >= dbMinimunlevelID)

=> is lambda operator, whereas >= (greater or equal) is used for comparing

Zbigniew
  • 27,184
  • 6
  • 59
  • 66
4

You're creating a lambda expression by using => ... it is a right facing arrow.

Use >= instead for comparisons.

NominSim
  • 8,447
  • 3
  • 28
  • 38